Send PUT request using REST-Assured

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

PUT request is modeled as an insert or update. The difference between POST and PUT is, POST will return status code 201 and PUT will return 200, and POST will create a new resource but, PUT will update the existing resource. This means we will have to mention which resource we wish to update in the URI itself like below.
Here 100 is the ID of a resource to be updated.

PUT using REST-Assured

We created a HashMap here to store all the entries which needs to be updated. We will store all the elements using map.put() method of HashMap. Then we will provide HashMap object “map” to body() method, so that all the data in map object will be sent with the put request using put() method.

Please note we provided “/100” in put() method, which provides the information about the resource we want to update. And you can see we did validation for the status code and title.

Series Navigation<< Send POST request using REST-AssuredSend DELETE request using REST-Assured >>