Forum Discussion

MRutten's avatar
MRutten
Occasional Contributor
3 years ago
Solved

How define testscenario for REST requests using values of previous response as resource path.

Hello,

 

GOAL:

My goal is to functional test the available REST services using a scenario with several steps. Each step uses values from the response of previous teststeps. 

 

SCENARIO:

- start scenario with a GET with query parameter :

             http://localhost:8080/ztcplus-rt/api/v1/zaken/query?bsn=13

- in the response there will be 1 or more 'Zaken'

   "results" : [
      {
       "identificatie" : "077214954",
       "omschrijving" : "Test hack bsn 2",
        "resultaat" : "http://localhost:8080/ztcplus-rt/api/v1/zaken/statussen/55bef47c-5b8d-4d08-aa84-6cee7af4b967",
        "startdatum" : "06-04-2022",
        "url" : "http://localhost:8080/ztcplus-rt/api/v1/zaken",
        "uuid" : "583cb12f-be34-45fd-8bd7-a2aa7663a3df",
        "zaaktype" : "http://localhost:8080/ztcplus-rt/api/v1/catalogi/zaaktypes/36f0fb51-5e71-401e-9650-6721fb3af34d"
      }

 

- the next teststep is a GET referencing the uuid delivered in the response of the previous request: 
http://localhost:8080//ztcplus-rt/api/v1/zaken/583cb12f-be34-45fd-8bd7-a2aa7663a3df

 

QUESTION

How can i create the second teststep? How can i reference the UUID in the Resource path of the GET request? 

See attached screenprint

 

Kind regards,

Maarten

 

Maarten

  • Hey MRutten 

     

    so you want to transfer the UUID value from the first request's response and pass it onto the second step's URI parameter - yes?

     

    Yeah - there's a number of ways to do this.

     

    Going with the straightforward option

     

    1 of the ways is as follows:

     

    1.  Ensure both test steps are already in your test case

    2.  Submit the first request ONLY to generate a response (displaying the UUID you need)

    3.  Within the 'Request' form of the second test step request within the UUID_REF parameter, right click in the 'Value' field (to launch the context menu) - see screengrab

     

     

    4.  Click on 'Get Data' to launch the next screenshot

    5.  In the 'Test Step' column, select the first test step in your test case, this generates the content in the 'Properties' column.  Click on the 'Response' value and click 'Add' to launch the next screenshot

    6.  Within the generated window above - click on the relevant field (the UUID) value and click on 'OK' to save and close - and that's it!

     

    If you look in the UUID URI parameter value field on the second request, its displayed value will be something like ${FirstTestStepName#Response#$['value'][0]['UUID']}

     

    Hit me back if you have any problems,

     

    Cheers,

     

    Rich

     

2 Replies

  • richie's avatar
    richie
    Community Hero

    Hey MRutten 

     

    so you want to transfer the UUID value from the first request's response and pass it onto the second step's URI parameter - yes?

     

    Yeah - there's a number of ways to do this.

     

    Going with the straightforward option

     

    1 of the ways is as follows:

     

    1.  Ensure both test steps are already in your test case

    2.  Submit the first request ONLY to generate a response (displaying the UUID you need)

    3.  Within the 'Request' form of the second test step request within the UUID_REF parameter, right click in the 'Value' field (to launch the context menu) - see screengrab

     

     

    4.  Click on 'Get Data' to launch the next screenshot

    5.  In the 'Test Step' column, select the first test step in your test case, this generates the content in the 'Properties' column.  Click on the 'Response' value and click 'Add' to launch the next screenshot

    6.  Within the generated window above - click on the relevant field (the UUID) value and click on 'OK' to save and close - and that's it!

     

    If you look in the UUID URI parameter value field on the second request, its displayed value will be something like ${FirstTestStepName#Response#$['value'][0]['UUID']}

     

    Hit me back if you have any problems,

     

    Cheers,

     

    Rich

     

  • MRutten's avatar
    MRutten
    Occasional Contributor

    Thanks for the clear step-by-step explanation!

     

    Maarten