API testing with Jmeter: how to get the dynamic token and insert it into next HTTP request



  • 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":"akhileshs@beckett.com","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



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



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2