0

Below is the response I am getting from my API and each time I use it, it'll generate a fresh token.

Return Response:-

{"status":true,"msg":"Login successfully","result":{"user_id":"9999940413020708","username":"Akhileshs","email":"[email protected]","last_login":"2016-05-26 06:57:41","first_name":"Akhilesh","last_name":"Singh","gender":"M","dob":"2016-03-30","token":"40df7635009e551beab7"}}

How do I get the token and user id and put these values into next HTTP request

Please let me know any further information is needed from my end.

thanks

Adnan
1852 silver badges10 bronze badges
asked Jun 8, 2016 at 11:28

3 Answers 3

1

It's fairly simple:

  1. Add JSON Path PostProcessor as a child of the request which returns above JSON
  2. Configure JSON Path PostProcessor as follows:

    • Variable names: anything meaningful, i.e. token
    • JSON Path Expressions: $..token
    • Other fields may be left as they are
  3. Refer extracted value as ${token} where required

JSON Path PostProcessor Demo

References:

answered Jun 9, 2016 at 4:32
0

That's a scenario that exists in most of the cases wherein you need to extract the authentication token post login. You should use the Regular Expression Extractor post-processor to extract the token, id or anything of this sort. Go to the Thread group and right click and then in the post-processor options you'll find the regular expression extractor option. You'll need to write a regex expression to extract the token or id and give a reference name as well that you can use as a variable in your next requests.

Thanks!

answered Jun 8, 2016 at 11:47
0

1) Add a Post Processor to parse the access token--> JSON Path Extractor and add the Below Expression

$.result.token

2) Define a variable for to save the access token value, in the JSON Path Extractor to save the parsed value. example variable name is 'token'.

3) whereever the access token is required invoke its value, just be defining as,

${<<Access token variable>>}
 example --> ${token}
answered May 14, 2018 at 10:51

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.