Forum Discussion

maheshkr's avatar
New Contributor
9 years ago

How to use an array object in the request and iterate

Can someone help please ?


From JSON response below I'm able to get the values of "Name" element and write it to a property variable "xy"as a string using below groovy step, however I do not know how to pass the [] value from the Property  to the JSon request as an URL parameter ? second part is I want to iterate the request dynamically based on how many Name(s) are getting returned in the response and assert accordingly, any quick help is much appreciated, thanks for reading.


Groovy Step 

def prop1 = context.testCase.getTestStepByName("TestData")


Output of above step set in property ..


Name = [UnitApplication,WebUI ]


JSON Response


"Id": 1,
"Name": "UnitApplication",
"APIKey": "e28de5d0-39ce-4a4c-90b0-fe9a95d02021",
"AssemblyId": null,
"Distributore": null,
"Configuration": null,
"Set": [],
"Rou": [],
"Pattern": []
"Id": 2,
"Name": "WebUI",
"APIKey": "74e162cb-9872-4a1b-bd94-72aa4b6e44ca",
"AssemblyId": null,
"Distributor": null,
"Configuration": null,
"Settings": [],
"Routes": [],
"Pattern": []

4 Replies

  • nmrao's avatar
    Champion Level 3
    Do you mean to say, your test case contains
    Step 1: REST and you get the above response
    Step 2 : Another request where you need to pass data as query parameters from step1 to this step request?
      • maheshkr's avatar
        New Contributor

        Just chasing my earlier post, can someone try help if you have done a similar thing ?


        Basically if there is an another way to do then please feel free to share 


        Just like to  summarize again my problem, I would like to get all the element value (A) from the Rest JSON response, store it an a property and then pass it to the next Rest call as an URI parameter and then iterate it based on the no of elements (A) returned in the original response.