user3531858
user3531858

Reputation: 155

Jmeter and Json, extracting and using variables for another request

I'm new to JMeter and I'm probably missing something quite simple...

Note: I'm using a json add-on as well.

After making a request, I extract a value from the response. If I check the view results I'm able to see the correct value in the variable I created.

-Initial extraction of value- My Initial response

-how I tried to use my new value for a new request- My Second Request Using the Variable

If I try use the variable in another request, I receive an error because the variable is now the default value.

Default value being used for variable

What am I doing incorrectly that makes the second post request to use the default value and not the value it captured (if I did that correctly).

Thanks

Upvotes: 3

Views: 9187

Answers (2)

Hugo L.M
Hugo L.M

Reputation: 1083

2 years later (March 2018), with Jmeter version 4.0, solution it's the same.

With the new interface, simply by dragging the json extractor on the http request, the json is limited to perform the extraction operation on it, maintaining the results.

enter image description here

Upvotes: 0

vins
vins

Reputation: 15370

JSON Path Extractor is a Post Processor. It is not a Sampler. It should be the child element of the first request 'Create Order' in your test plan if you are going to extract from the 'Create Order' response. If it is in same level with other requests, the post processor will be executed for each and every samplers in the same level. That is why, You are able to see the value for the first time. Now Post processor tries to extract the value from the Debug Sampler as well. As Debug Sampler does not match your JSON extract condition, It sets the default value.

Upvotes: 3

Related Questions