Reputation: 33
I have some specific scenario for retrieving Access Token from API using jmeter. I need to implement following test case and have no idea how to implement this (I am new in jmeter):
{"RequestToken":"81d1fcd6146d41f69a966a2c083382c7","Expires":3600}
Thanks!
Answer of Dmitri T really helped me! Thanks a lot!
Upvotes: 3
Views: 4876
Reputation: 168002
If your response {"RequestToken":"81d1fcd6146d41f69a966a2c083382c7","Expires":3600}
is the full one you can add a Regular Expression Extractor Post Processor to GET request configured as follows:
token
{"RequestToken":"(.+?)","Expires":3600}
$1$
After that you can refer to extracted value as ${token}
or ${__V(token)}
in POST request.
If you need to deal with more complex JSON structures I would recommend using JSON Path Extractor available via JMeter Plugin. It allows fetching data from JSON responses in more "intelligent" way as big JSON entities cannot be easily parsed via regular expressions.
In this case relevant JSON Path query will look like $.RequestToken
.
See Using the XPath Extractor in JMeter guide for more details (scroll down to Parsing JSON
).
Hope this helps.
Upvotes: 4