I got the array response from the one API and I passed to the response to the other API. For example: Response from one API is {status:200,data:{name:"Manikyam", selected_products:[1,2,3,4,5]}
I need to iterate the selected_products from the response using foreach or other loop which is suitable of this.
Iterations like:
I tried some ways like using forEach but I haven't any luck.
The below answer assumes that your response is a valid JSON looking like:
Add JSON Extractor as a child of the request which returns the above JSON and configure it as follows:
product
$.data.selected_products.*
-1
Add ForEach Controller and configure it as follows:
product
product
That's it, if you add a Sampler as a child of the ForEach Controller, the controller will iterate all the variables so you will be able to refer each and every as
${product}
where required likehttp://dummy.com/product/${product}
Demo: