In the last two tutorials we have learnt about Response Status Code, Status line and Headers. We will continue with the same example in those tutorials and verify the body if the Response. If you have not gone through the first two tutorials then I would suggest you go through these links

In this tutorial we will learn about How to Read JSON Response Body using Rest Assured? and How to Validate Content of a Response Body?



Read JSON Response Body using Rest Assured

Let us continue with the example of Weather web service that we used in the previous tutorials. When we request for the Weather details of a particular city, Server responds by sending the Weather details of the city as the Response Body. Response interface contains  two methods to get the Response Body

  • Response.body() : returns ResponseBody
  • Response.getBody() : returns ResponseBody


Read Json Response Body using Rest-Assured

Using these methods we can get an Object of type io.restassured.response.ResponseBody. This class represents the Body of a received Response. Using this class you ca