简体   繁体   中英

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- 我的初步回应

-how I tried to use my new value for a new request- 我的第二个请求使用变量

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

默认值用于变量

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

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.

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.

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM