Reputation: 134
I have an HTTP request that returns a JSON object that contains multiple urls (mostly image resources). I do not know the number of the urls that will be in the response JSON and that number may vary during time. I need to create an HTTP request for each of the urls that i received.
Is it possible to create HTTP Request samplers while running the JMeter flow? Is there a different solution one can advise me to do in order to send HTTP requests to the list of the urls?
Thanks
Upvotes: 1
Views: 348
Reputation: 167992
Given you have the following JSON:
{
"urls": [
{
"url": "http://example.com"
},
{
"url": "http://jmeter.apache.org"
},
{
"url": "http://jmeter-plugins.org"
}
]
}
You can extract the URLs into JMeter Variables using the following JSON Extractor setup:
it will give you the following JMeter Variables:
url_1=http://example.com
url_2=http://jmeter.apache.org
url_3=http://jmeter-plugins.org
url_matchNr=3
now if you add ForEach Controller and configure it like:
you will be able to refer the URLs as ${current_url}
in the HTTP Request sampler which is the child of the ForEach Controller
Upvotes: 3