Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to Use extracted JSON array data in loop in JMeter?

I have a workflow where user can create tickets using equipment numbers.
Now from API response I’m getting equipment numbers. So using JSON extractor to store those in variable "equipmentNumber", with "match no. -1" (so getting all the equipment numbers which are present in response lets say 10 numbers)
Now in next post request if is use variable "${equipmentNumber_1}" then first value from response gets passed.
But I want to run this post request 10 times and use all equipmentNumber values in loop, which I am getting like equipmentNumber_1, equipmentNumber_2, equipmentNumber_3…till 10. So how to achieve that ?

[JSON Extractor](httpsenter image description here://i.sstatic.net/wZ858ZY8.png)

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

If you add a Debug Sampler or PostProcessor after the JSON Extractor you will see the following variables defined:

equipmentNumber_1=foo
equipmentNumber_2=bar
equipmentNumber_3=baz
equipmentNumber_matchNr=3

In order to loop through them add a ForEach Controller and configure it like this:

enter image description here

Ądd your POST request as a child of the ForEach Controller and it will iterate as many times as there are matches in your JsonPath expression

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading