3

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):

  1. Send GET request to server.
  2. Server will return following response: {"RequestToken":"81d1fcd6146d41f69a966a2c083382c7","Expires":3600}
  3. After that I need to send POST request to server with parameter of "RequestToken" from step #2.

Thanks!

Answer of Dmitri T really helped me! Thanks a lot!

2

1 Answer 1

4

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:

  • Reference Name: anything meaningful, i.e. token
  • Regular Expression: {"RequestToken":"(.+?)","Expires":3600}
  • Template: $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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.