From the course: Java: Automated API Testing with REST Assured

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Solution: Verify API response

Solution: Verify API response - Java Tutorial

From the course: Java: Automated API Testing with REST Assured

Start my 1-month free trial

Solution: Verify API response

(upbeat music) - [Instructor] How'd you do? Let's walk through the solution of verifying the response to this get product request. First, we create a new method. And inside of this method, we declare the endpoint, which is read one. And then we say, given the ID is 18, when we make a get request to this read one endpoint, then we can assert that. And now we want to assert the three parts of the response, starting with the status code, which should be 200, meaning the get request was successful. Next, we want to make sure that the data was returned to us in JSON format. So we verify that the content type header has a value of application JSON. Then the final part of the response is the body. And the challenge was to verify each of its fields. These can be verified in any order, as long as there's an assertion for each one. The ID should be 18. The name should be equal to multivitamins, 90 capsules. And if you use the…

Contents