API Testing Tutorial Part 23 – Sending DELETE Request in Postman



Hello Folks,

As part of our API Testing series, we will see “Sending DELETE request in Postman”.

First of all we need some APIs to test. There are many public APIs available which you can use for testing purpose. I will suggest you to register at below site to use free APIs for testing:

GoRest API for Testing

Above website provides you APIs for basic operations i.e. CRUD which we have already learnt in previous posts.

I will keep sharing links of public APIs for testing.

We have already covered about:

Sending GET request in Postman

Sending POST request in Postman

Sending PUT request in Postman

Sending PATCH request in Postman

In this post we will going to learn sending a DELETE request through Postman.

DELETE HTTP method:

An HTTP DELETE method is used to delete an existing resource from collection of resources. The DELETE method requests the origin server to delete the resource identified by the Request-URI. On successful deletion of resource, it returns  200 (OK) and 204 (No Content) status code. It may return as 202 (Accepted) status code if request is queued. 

It is not a safe method as it performs on modification of data. If we hit the same request again after first hit, it will give you 404 ( Not Found) . So DELETE request are idempotent after second call onward. 

If a DELETE request includes an entity body, the body is ignored. 

RFC-2616 defines it as below:

” The DELETE method requests that the origin server delete the resource identified by the Request-URI. This method MAY be overridden by human intervention (or other means) on the origin server. The client cannot be guaranteed that the operation has been carried out, even if the status code returned from the origin server indicates that the action has been completed successfully. However, the server SHOULD NOT indicate success unless, at the time the response is given, it intends to delete the resource or move it to an inaccessible location.

A successful response SHOULD be 200 (OK) if the response includes an entity describing the status, 202 (Accepted) if the action has not yet been enacted, or 204 (No Content) if the action has been enacted but the response does not include an entity.

If the request passes through a cache and the Request-URI identifies one or more currently cached entities, those entries SHOULD be treated as stale. Responses to this method are not cacheable.”

To perform a DELETE request below steps are performed:

  1. Select the “DELETE” in http methods drop down.
  2. Pass the request URI in address bar of Postman.
  3. Add authorization if applicable.
  4. Add headers if applicable.
  5. Click on Send button.

We can get DELETE URI  from above website. In real time, developer will provide you all these details.

URI –https://gorest.co.in/public-api/users/{userID}

GoRest provide you a DELETE API to update user details and you need to pass userID in URI itself. We will be Deleting details of user with id 1158. You can get valid user id by hitting a GET request. So our final URI for DELETE will be:

URI –https://gorest.co.in/public-api/users/1158

Detailed steps to hit a DELETE request in Postman:

1. Select the “DELETE” in http methods drop down, pass DELETE URI in address bar.

2. To hit DELETE request, you need to pass authorisation. You need to pass access token for GoREST APIs. You need to sign up and go to profile to get access token as shown below:

 

 

3. Go to “Authorization” tab and select “OAuth 2.0” in “Type” drop down. Paste copied access token in “Access Token” text box.

4. Hit the “Send” button.

If we hit the same request again, you will see the message as “The requested resource does not exist.” with status code as 404.

More about API Testing in upcoming posts. Stay tuned.

If you have any doubt, feel free to comment below.
If you like my posts, please like, comment, share and subscribe.
#ThanksForReading
#HappyApiTesting



Author: Amod Mahajan

My name is Amod Mahajan and I am an IT employee with 6+ years of experience in Software testing and staying in Bengaluru. My area of interest is Automation testing. I started from basics and went through so many selenium tutorials. Thanks to Mukesh Otwani as his tutorials are easy and cover basics to advance. I have habit of exploring concepts by deep diving. I used to make notes. I thought of sharing my knowledge through posts and now I am here. #KeepLearning #ShareLearning

Leave a Reply

Please wait...

Subscribe to new posts to become automation expert

Want to be notified when my new post is published? Get my posts in your inbox.
%d bloggers like this: