Hello Folks,

As part of our API Testing series, we will see “Sending PUT 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

I will keep sharing links of public APIs for testing.

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

We have already covered about:

Sending GET request in Postman

Sending POST request in Postman

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

PUT HTTP method:

An HTTP PUT method is used to primarily update the resource information but  it also can be used to create a new resource (Depends on API development) if requested resource is not available.  If PUT request is made to update resource, it should return 200 (OK) and 204 (No Content) status code. If PUT request is made to create a new resource, it must return a status code 201( Created). 

PUT is not a safe method as it performs data creation and modifications but it is idempotent as if we hit the same request again, it operates on same existing resource. But note here that a PUT request can be made as non-idempotent as well.

To perform a PUT request below steps are performed:

  1. Select the “PUT” in http methods drop down.
  2. Pass the request URI in address bar of Postman.
  3. Pass request body in desired format under Body tab.
  4. Add authorization if applicable.
  5. Add headers if applicable.
  6. Click on Send button.

URI and request body we can get 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 PUT API to update user details and you need to pass userID in URI itself. We will be updating details of user with id 1145. You can get valid user id by hitting a GET request. So our final URI for PUT will be:

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

Request Body in JSON:

User is supposed to pass a full payload to a PUT request irrespective of how many data your are updating. But it is not hardcore rule as it all depends upon implementation of API. For above URI, we will send below payload :

However, above PUT request will work without all fields as well. You can try by sending just “first_name” in request body.

Detailed steps to hit a PUT request in Postman:

1.Select the “PUT” in http methods drop down, pass PUT URI in address bar and copy request body under “Body” tab. You can see all these steps in details in previous post.

2. To hit PUT 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. You can see response in “Body” tab of Response section of Postman. (Bottom part). Response in JSON format and it gives you updated details about user.

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

2 thoughts on “Postman Tutorial Part 8 – Sending PUT Request in Postman

Leave a Reply