Ask a Question

REST Response: executing several teststeps for every object in REST response. How?

Occasional Contributor

REST Response: executing several teststeps for every object in REST response. How?


Execute several Test steps (GET requests) for every Object in a REST Query Response.



I want to build a Functional Test

1. Execute GET Query request that will have several results in the response (there is a "count" element in the response with the number of results)

Count 2022-04-13_14-36-06.png

2. For every result in the response i want to execute several GET requests to obtain the details of each Result 



1. Store the value of "count" in a Property so i know how many loops i have to perform

2. Define another Property 'loopCount' that will count the number of loops

3. Use the property 'loopCount' to refer to elements of a certain Result 


In one of the Test Steps a Request proprerty is used that refers to the first Result: 
${Query Zaken - GET by bsn#Response#$['results'][0]['uuid']}

I was thinking to make this dynamically using the 'loopCount' property.

${Query Zaken - GET by bsn#Response#$['results'][<some reference to property loopCount>]['uuid']}


LoopCount 2022-04-13_14-53-09.png



1. Is this the way to go or are there nicer/better solutions possible?

2. How can i make a dynamically reference to a certain Result in the list with Results in subsequent GET requests?  


Kind regards,



Hello @MRutten ,
here are my answers:


To 1)
It depends on your skills and what are for you nice. A another way is to use more Groovy Script. Without Groove you can not resolve your issue.


To 2)
At same way you get the value for uuid.
${Query Zaken - GET by bsn#Response#$['count']}


To 3)

You can use nested properties. See below the link. There is the nested properties described and an example.

But this not enough. You need a loop and you can realize this with a Groovy Script - see below.


You need a Groovy script after the test step with the query. This script check the count. Is the actual count greater then max count value (size of the array in the JSON) the script do nothing and the test case ends else increase the property count in the test step properties (first test step in your test case) and then in the script give the command to jump in to the query test step (testRunner.gotoStepByName("Query Zaken - GET by bsn")). You get the value from the count from the test step "Properties" with ${Properties#count}. This test step is first test step in you test case.
Finally you must write a script for the test case setup script. In this script you must initialize the count property in the test step "Properties" (context.getTestCase().getTestStepByName("Properties").setPropertyValue("count", 0)).

I hope that my hints are helpful.




Super Contributor

@MRutten ,

using JSON DataSource might help here.


An example for illustration (using famous Pet store use case from )



How it works:

  1. GetPets: We get all pets with a GET query
  2. PetsDataSource: Parsing the GetPets response into a Data Source
  3. GetPetDetail: Using the value within a request
  4. Data Source Loop: Taking another set of values from Data Source and jump to GetPetDetail.

There may be more complex processing between GetPetDetail and the end of the loop if needed.

Here's the configuration of the Data Source:




Best regards,

Occasional Contributor

Hi @giovanni_favara,


Thanks for your clear explanation! 


I have defined a Custom Test Case Property 'loopCount'.

In a Groovy script i assign a value to this property: 

testRunner.testCase.setPropertyValue( "loopCount", "0" ) 


But now i am struggling with using this property 'loopCount' in the script that determines the value of the Request parameter UUID_REF.

(see second screenprint in my initial Question)


This doesn't work:

${Query Zaken - GET by bsn#Response#$['results'][${loopCount}]['uuid']}


What am doing wrong?


Kind regards,




Occasional Contributor

@KarelHusa works like a charm! Thanks!

Daag meneer @MRutten , 🙂

${loopCount} is wrong.
Use ${#Properties#loopCount}.
After ${# you must wirte the location, in your case the properties test step. On the end you write the name of the property. In your example is the name of the property #loopCount}.


Best wishes, Giovanni


Occasional Contributor


That did the trick.

This DOES work:

${Query- GET by bsn#Response#$['results'][${#TestCase#loopCount}]['uuid']}


('Daag meneer' -> 'Geachte heer' or 'Hallo meneer'  but it is too formal on a community) 😉 

Showing results for 
Search instead for 
Did you mean: