Chirag Patel
Chirag Patel

Reputation: 21

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.

Upvotes: 2

Views: 654

Answers (2)

Dmitri T
Dmitri T

Reputation: 168157

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.

Upvotes: 0

klingac
klingac

Reputation: 463

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}

Upvotes: 4

Related Questions