Send DELETE request using REST-Assured

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

The syntax for Delete request is no different, we just have to call the delete() method instead of get(). Also we need to provide the URI of a resource on which want to perform Delete operation.

We will send a Delete request on the resource https://jsonplaceholder.typicode.com/posts/1
Please note “1” is the our resource identifier. We are requesting a service to delete resource “1” by providing its URI and sending it with a delete() method. Here we will validate response in header. Below is the header response we will receive after sending the delete request.

delete-request

Access-Control-Allow-Credentials →true
CF-RAY →3aec4d6f23378460-HKG
Cache-Control →no-cache
Connection →keep-alive
Content-Length →2
Content-Type →application/json; charset=utf-8
Date →Mon, 16 Oct 2017 16:12:56 GMT
Etag →W/”2-vyGp6PvFo4RvsFtPoIWeCReyIC8″
Expires →-1
Pragma →no-cache
Server →cloudflare-nginx
Vary →Origin, Accept-Encoding
Via →1.1 vegur
X-Content-Type-Options →nosniff
X-Powered-By →Express

Please note JSONPlaceHolder doesnt allow us to delete their resource from server but, it will not throw any error to us. If you try to get that resource again with the GET method, you will see the data there, we used it just for the purpose of learning.

Series Navigation<< Send PUT request using REST-AssuredREST-Assured Extracting values from the response. >>