Is anyway to verify JSON Response got from RestFul API in JMeter?
I am getting below response:
{"workingfrom":[{"id":1234,"type":"office","name":"N1"},{"id":5678,"type":"home","name":"N2"}]}
JSON Extractor- It is a handy tool to execute JSON Path expressions against JSON responses and storing the result into a JMeter Variable. If the response of any request is in JSON then we can use this extractor.
To send a POST HTTP Request with the JSON Data inside the body, need to add, HTTP Header Manger into your request and set the name as 'content-type' and value as 'application/json' this will attached into HTTP request header and what ever the data inside your request body will send as json format.
JSON Assertion is another way (in JMeter 4). It can easily assert whether or not a node was present. It can even assert on the node value (regex or otherwise).
Just put groovy-all-2.3.2.jar in the /lib directory of your JMeter installation and then you can use the Groovy JsonSlurper wrapper. After you start JMeter with that .jar in the path, then you can add a JSR223 Sampler that uses Groovy script.
Also, if you install the JMeter plugin packs, there is a JSON Path Extractor plugin, which has worked well for me.
These are 2 very nice alternatives to using regular expressions. If you are writing a lot of tests, either of these 2 methods will be superior.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With