Forum Discussion

fazlook's avatar
fazlook
Frequent Contributor
9 years ago
Solved

How to get the REST PUT response from request1 and use it in another REST PUT request2

Say I have PUT reuqest1, it creates an ID for me in the  response in JSON format. PUT request1 { "name": "Soap", "family": "UI" } response is { "id": "2", "name": "Soap", "family": "UI" } ...
  • fazlook's avatar
    fazlook
    9 years ago

    So use Script assertion in my first put ? so this is the first Test Step ?

    Can I use that value in both Test Steps and Test Case levels ?

     

    **Update1**

    I worked the first step. Now I used this in my next step (a second PUT request to update the name)

     

    {
    "id": ${#TestCase1#ID}
    "name": "nameupdate",
    "updateBy": null
    } and got this message

     

    [{
    "context": null,
    "message": "Request body was not specified, or was improperly formatted and could not be deserialized."
    }]

     

    **Update2**

    I was missing a , at the end of "id": ${#TestCase1#ID}. It is now fixed, however, I have a new problem now. It is creating a new ID everytime I send the request again. It should update the name not creating a new id :( 

     

    **Update3**

    My test case name is : TestCase1 , so if I use "id": ${#TestCase1#ID} or "id": ${#Test1#ID} or "id": ${#Test#ID} , they are behaving the same as Update2

     

    rupert_anderson you might help as well ? :) 

     

    **Update4** 

    I needed to use quotation marks like that:  '${#TestCase#ID}' in the body of my next PUT request for this to work :)