How to use the response value of one step to another next step in Web Service project?

In a Web Service project, the user can use the first response of the recorded step to the next steps by storing the response value as a variable. Ideally, the first response of the API call will be treated as an input for the next API call. Refer to the below steps.

We have two steps recorded for the Web Service project.

  • POST.rest.testcases : This API will create a Test Case in QMetry.

  • POST.rest.search: This API will search the Test Case in QMetry. (searching the Test Case by its issue key)

  • Here we will be using the first API response value for the next API call. The first API POST.rest.testcases will create a Test Case and we will be using the newly created Test Case key in the next POST.rest.search API call.

  • First, the user would need to store the variable value of the POST.rest.testcases API call.

    • Click on the edit button under the Actions tab.

       

    • Step A: Click on the Send button >> In the response, expand the Body> data> 0 as shown in the screenshot.

    • Step B: Here we will be storing the “entityKey” value as a variable as it is a unique value of the Test Case and can be used to search the Test Case.

    • Step C: Click on the more option of the “entityKey“ >> Select “Store to“.

       

    • Add the Variable name >> Save.

       

    • This will create new custom steps with the stored response variable.

       

  • Now, we will be using this store variable value in the next API call POST.rest.search

    • Click on the edit button under the Actions tab.

       

    • Click on the “Body“ and add the stored variable name “TestCaseKey“ as a value and save.

       

  • Since we have created a custom step, we have to convert the steps into the code and export it to the project and run it through the terminal using the “mvn“ command.