Lea2501
Lea2501

Reputation: 351

How to use a value from JSON response from sample 1 as sample 3 request body in JMeter

I'm having a problem with a request i have to make with Jmeter that needs the value of a variable taken with "JSON Extractor" in a previous sample.

Basically if i get the value from a JSON response and store it in a variable with "JSON Extractor", i can only use the variable value in the next sample, but not in other samples.

Here's what im doing:

1) im taking the value of this variables with JSON Extractor from sample number 1:

deviceId

customerId Get deviceId value from response

Get customerId value from response

2) im taking the value of this variable with JSON Extractor from sample number 2: Get token value from response

3) Use those values from variables from samples 1 and 2 in the request body in sample 3: Use those variables in Sample 3 request body

4) I don't get the values from the variables from sample number 1 in request body from sample 3, only the one from sample number 2: enter image description here

Upvotes: 1

Views: 136

Answers (1)

Dmitri T
Dmitri T

Reputation: 168092

JMeter Variables (as well as functions and properties) are case sensitive so customerId and customerID are different beasts. Make sure to use exactly the same value as you define in the "Names of created variables" section and your test should start working as expected (assuming your JSON Path query is correct)

You can check which JMeter Variables are available (along with their values) using Debug Sampler and View Results Tree Listener combination.

Upvotes: 1

Related Questions