0

I have setup a ForEach Controller to execute multiple HTTP requests but I would like to then extract JSON values from the response bodies from each of the HTTP requests.

When I try to add a JSON Extractor PostProcessor to the HTTP Request, I am only able to get a json value from the last HTTP Request. Is it possible to get values from all of the HTTP requests?

2 Answers 2

1

You're getting the values from each HTTP Request, you just overwrite the previous value when the next iteration of the ForEach Controller starts, you can double check yourself by adding Debug Sampler after the HTTP Request sampler under the ForEach Controller

Just add ${__jm__ForEach Controller__idx} pre-defined variable as a prefix or postfix for the name of the created variable in JSON Extractor so on each iteration it will create a separate JMeter Variable holding the current value extracted from the response.

Example configuration:

enter image description here

Demo:

enter image description here

Sign up to request clarification or add additional context in comments.

3 Comments

Thank you very much for the detailed answer.
On a side note, what would be the easiest way to iterate through the variables if I wanted a specific value?
@Dmitri T Can you please answer stackoverflow.com/questions/79672065/…
-1

JSON extractor is ok but something that you can try and is more flexible i add beanshell post processor and choose your language, then you can extract the JSON from HTTP requests. You can choose java as language and use following code to extract the JSON as string

String jsonString = prev.getResponseDataAsString();

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.