Postman DELETE request deletes a resource already present in the server. The DELETE method sends a request to the server for deleting the request mentioned in the endpoint. Thus, it is capable of updating data on the server.
Before creating a DELETE request, we shall first send a GET request to the server on the endpoint: http://dummy.restapiexample.com/api/v1/employees. The details on how to create a GET request is explained in detail in the Chapter onGET Requests.
On applying the GET method, the below Response Body is obtained −
Let us delete the record of the id 2 from the server.
Follow the steps given below to create a DELETE request in Postman successfully −
Step 1 − Click on the New menu from the Postman application. The Create New pop-up comes up. Then, click on the Request link.
Step 2 − SAVE REQUEST pop-up comes up. Enter the Request name then click on Save.
Step 3 − The Request name (Test1) gets reflected on the Request tab. We shall select the option DELETE from the HTTP request dropdown.
Then enter the URL - http://dummy.restapiexample.com/api/v1/delete/2(endpoint for deleting the record of id 2) in the address bar.
Here, in the DELETE request, we have mentioned the id of the resource in the server which we want to delete in the URL.
Step 4 − Click on the Send button.
Once a request has been sent, we can see the Response code 200 OK populated in the Response. This signifies a successful request and the request we have sent has been accepted by the server.
Also, information on the time consumed to complete the request (734 ms) and payload size (652 B) are populated. The Response shows the status as success. The record id 2 gets deleted from the server.
After deletion of the record with id 2, if we run the GET request on the endpoint: http://dummy.restapiexample.com/api/v1/employee/2, we shall receive 401 Unauthorized status code.