'How to get single parameter from JSON response in JMeter and use in other HTTP request?

I want to fetch one parameter from JSON response in the JMeter tool.

Currently, I am calling one API through JMeter and in response I got various parameter in jason format, but I want to fetch single parameter from that request and want to call another API Using that Parameter.



Solution 1:[1]

Use extractors to parse response and get any data from it. E.g. if your JSON response looks like this:

{
  "TITLE": "Empire Burlesque",
  "ARTIST": "Bob Dylan",
  "COUNTRY": "USA",
  "COMPANY": "Columbia",
  "PRICE": "10.90",
  "YEAR": "1985"
}

You can use this options:

  1. JSON Path Extractor JSON Path Extractor
  2. JSON extractor JSON extractor
  3. Regex extractor Regexr extractor
  4. SmartMeter's Boundary Body extractor - fastest solution, but you need SmartMeter Boundary body

Of course you can use Beanshell, JSR22 or jQuery extractors.

After extracting data to variable my_title you can use this variable in another requests like this ${my_title}

Solution 2:[2]

Since JMeter 3.0 there is JSON Extractor which can execute arbitrary JSON Path queries against responses, this way you will be able to extract the data you require and store it into a JMeter Variable for later re-use.

See API Testing With JMeter and the JSON Extractor guide for comprehensive information and real-life use-case.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 user7294900
Solution 2 Dmitri T