1
votes

I am trying to test REST APIs using JMeter. My lead told me to do load testing on each API using JMeter. Currently I am testing a Get API request, and I am getting the below JSON response body with double quotation.

"https://api.rewards.com:/lists/v1/listcontainer/1?ts=20190221004021&auth=EngineeringSolutions:ydvMMlY2uxiKG0yuwh1IbVgR2mfqTQaQncTEaMr+Ef0="

Now I have to pass this JSON body to another HTTP request and test the API.

My questions:

How can I get the values of ts and auth using split method like (ts=20190221004021 and auth=EngineeringSolutions:ydvMMlY2uxiKG0yuwh1IbVgR2mfqTQaQncTEaMr+Ef0=) and store them into two different variables and print them on log view.

I am trying to get ts and auth value from the json response using split method. I am able to split the URL into two by using the below code. But, this is not my solution. I want to get 'ts' and 'auth' values and store them in two different variables.

enter image description here

Can anyone guide me how I can trim and split the JSON response?

1

1 Answers

0
votes

To parse JSON with JMeter you need to add the JSON Extractor to your test plan:

  1. Right click on your Get API request where you are getting the JSON
  2. Add –> Post Processors
  3. JSON Extractor.
  4. In the JSON Path expressions field specify your JSON path to parse the JSON response
  5. Set up variables names in Names of created variables, for example ts and auth
  6. Use this variables in the next request as: ${ts} and ${auth} for example:

    https://api.rewards.com:/lists/v1/listcontainer/1?ts=${ts}&auth=${auth}=

Check this article to get more ingormation about JSON and other extractors:
Using JMeter extractors