Passing data response of first request to second request in Jmeter
Passing data response of first request to second request in Jmeter
I have a POST request that is similar to this:
https://abc.qa.net/teachers
The response of above request is similar like this:
teacherUuid":"eb57eb97-0a9d-4b51-a237-1f6610983167"
Then, I have a PATCH request that is similar to this:
https://abc.qa.net/teachers/{teachersUuid}
Problem Statement:
I want to make two request in Jmeter. The first request (POST) generates a new id for me and then I want to use the same id to make second request (PATCH) in Jmeter. Note that, the second id will be passed via URL. How I can achieve this functionality in simple way?
1 Answer
1
Your response body seems to be JSON therefore JSON Extractor is your friend. Add JSON Extractor as a child of the first request and configure it as follows:
teachersUuid
$.teachersUuid
Refer the extracted value as ${teachersUuid}
where required, i.e. amend Path section of your 2nd HTTP Request sampler to look like:
${teachersUuid}
/teachers/${teachersUuid}
More information:
Thanks for the quick reply. I tried exactly the same steps you mentioned above and I'm facing an error now in the 2nd call where I passed the JSON Path expressions: {"reason":"invalid_parameter","errors":[{"code":400,"title":"Invalid query parameters","detail":"Invalid Parameter: teachersUuid format is invalid!","source":{"pointer":"string"}}]} I entered . in the JSON Path expressions.
– Ali Khan
Jul 3 at 9:29
I entered *.* in the JSON Path expressions.
– Ali Khan
Jul 3 at 10:25
I entered *.* in the JSON Path expressions.
I have a json response something like this:
{ : "data": : { : : "teacherUuid":"f45da0bd-717f-4ab0-a7e4-e56ba4fbn8e5" : } }
I believe i'm not able to make correct JSON Path expressions. Please guide.– Ali Khan
Jul 3 at 14:46
{ : "data": : { : : "teacherUuid":"f45da0bd-717f-4ab0-a7e4-e56ba4fbn8e5" : } }
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Please read Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers? - the summary is that this is not an ideal way to address volunteers, and is probably counterproductive to obtaining answers. Please refrain from adding this to your questions.
– halfer
Jul 3 at 7:06