How to send PUT Requests in Postman?

HOME

In this tutorial, we will create a PUT request in Postman and see how to execute it.

The PUT method is used to update resources available on the server. Typically, it replaces whatever exists at the target URL with something else. You can use it to make a new resource or overwrite an existing one. 

Difference between POST and PUT

  1. The PUT method is used to alter a single resource, whereas the POST method is used to add a child resource.
  2. POST method responses cannot be cached, while PUT method responses may.
  3. In PUT, you can use UPDATE queries, whereas, in POST, you can use CREATE queries.
  4. The client determines which URI resource to have in the PUT method, and the server decides which URI resource to have in the POST method.
  5. PUT is more specific, but POST is more abstract.
  6. If you send the same PUT request many times, the result will be the same; however, if you send the same POST request multiple times, the results will be different.
  7. The PUT method is idempotent, whereas the POST method is not.

We will use the following URL for this Postman tutorial.

	https://dummy.restapiexample.com/api/v1/update/1

Sample Request Body

{
   "name":"Update_Test",
   "salary":"40600",
   "age":"25"
}

To create the first PUT request in Postman, follow the following steps:

Step 1: Create a Collection, click on Collections, and then click on the “+” plus button.

Step 2:  Provide a name to the collection – “API Testing”.

Step 3: To create a new request, click on “Add a request” if it is a new Collection. Otherwise, click on the 3 dots and select “Add request”.

Step 4: Once you create a new request, then you will get the following window:

Step 5: Enter the “name” in the request. Here, the name is “UpdateUser”.

Step 6: Enter the “URL” in the address bar.

Step 7: Now, select the “PUT” request from the list of request methods.

Step 8 – Add a Request body to the Post request

For this, select the Body tab.

Now in the Body tab, select raw and select JSON as the format type from the drop-down menu, as shown in the image below. This is done because we need to send the request in the appropriate format that the server expects. Copy and paste the request body example mentioned at the beginning of the tutorial to the postman request Body. 

Step 9: Press the “Send” button.

Step 10: Once you press the send button, you will get the response from the server. Make sure you have a proper internet connection; otherwise, you will not get a response.

Status

You can check the status code. Here, we got the status code 200, which means we got a successful response to the request. In the case of new resource creation, the status code should be 201. But as this is a dummy API, we are getting a status code of 200.

Body

In the Body tab of the response box, we have multiple options to see the response in a different format.

Format Type

Each request has a defined response to it as defined by the Content-Type header. That response can be in any format. Such as in the above example, we have JSON code file.

Below are the various format type present in Postman.

XML

HTML

Text

Headers

Headers are the extra information that is transferred to the server or the client. In Postman, headers will show like key-value pairs under the headers tab. Click on the Headers link as shown in the below image:

We are done! Congratulations on making it through this tutorial and hope you found it useful! Happy Learning!!

Leave a comment