REST-Assured Extracting values from the response.

This entry is part 12 of 14 in the series REST Assured Tutorial

This tutorial will help you Extracting values from JSON response. We will learn How to fetch values from JSON response. For testing the real world API’s we need to get the response and validate that, perform test on it, and also need to store it for the record. Here we will store it in Response object. You need to import io.restassured.response.Response to use the Response class.

Here is a response snap from web browser, yes we can also see the the json data in browser, simply paste the uri in web browsers address bar :


Below is the code to extract the JSON response in Response object and later use it for validation.

Observing the response provided above, you can see the response also having an html url. That link is a resource URI of an API.

Sometimes our response will provide the URI to another API resource and will require us to hit that resource URI and perform validations there too. In some scenarios that URI may be dependent on the first URI, without calling the first URI we will not get the link to the next resource URI. So in last four lines of code you can see, we stored the URI to a string variable nextURI and then again we called that URI using get() and performed a validation on the new URI.

Series Navigation<< Send DELETE request using REST-AssuredJSON Schema Validation In Rest Assured >>