Jmeter - I have multiple values ( 250 values approx as a minimum ) returned from a Get Request in the form of array in json format , i need pass each of the value in the array as a parameter in next GET request
Request 1
> Get http://xxx/store1?
Response in json format looks like this
{"store1":"peirre","inventorylist":["item1","item2","item3"..........."item250"]}
I will need to use each one of item in next GET request like this to get is feautures like price , available quantity,production site etc.,
Request 2
Get https://xxx/store1/item1?
Get https://xxx/store1/item2?
Get https://xxx/store1/item3?
It would be easy when i can read the response and write each value in the array to CSV file so that my next get request would simply read the CSV file and fire all the requests
Is there a way to achieve this ???
Thank you in advance
Configure it as follows:
item
$.inventorylist.*
-1
Add ForEach Controller after the first HTTP Request sampler and configure it as follows:
item
current_item
Add HTTP Request sampler as a child of the ForEach Controller and use https://xxx/store1/${current_item}
in "Path" field - it will iterate through all the "item"s
2.Add a JSR223 post processor and initialize a counter as shown below
add the following condition
${__javaScript(parseInt(vars.get("counter"))<=parseInt(vars.get("List_matchNr")))}
as shown below
To your second get request add a JSR223 post processor and increment the counter as shown below
int counter = Integer.parseInt(vars.get("counter")) +1;
vars.put("counter",Integer.toString(counter));
${__V(List_${counter})}
to replace hardcoded value This loop will run through the match number and sends a request with each item to server
For more information on while loop please follow the link
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.