How to create a PUT request in Postman?

Rest AssuredPostmanREST API

A Postman PUT request is used to pass data to the server for the creation or modification of a resource. The difference between POST and PUT is that POST request is not idempotent.

This means invoking the same PUT request numerous times will always yield the same output. But invoking the same POST request numerous times will create a similar resource more than one time.

Before creating a PUT request, we shall first send a GET request to the server on an endpoint:http://dummy.restapiexample.com/api/v1/employees.

On applying the GET method, the Response body obtained is −

Now, let us update the employee_salary and employee_age for id 21 with the help of the PUT request.

Create a PUT Request

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 Request name then click on Save.

Step 3 − The Request name (Test1) gets reflected on the Request tab. We shall select the option PUT from the HTTP request dropdown. Then enter the URL -http://dummy.restapiexample.com/api/v1/update/21 (endpoint for updating the record of id 21) in the address bar.

It must be noted that in a PUT request, we have to mention the id of the resource in the server which we want to update in the URL. For example, in the above URL, we have added the id 21.

Step 4 − Move to the Body tab below the address bar and select the option raw.

Step 5 − Then choose JSON from the Text dropdown.

Step 6 − Copy and paste the below information in the Postman Body tab.

{ "name": "Jenette Caldwell","salary": "2000","age": "15"}

The overall parameters to be set for a PUT request is shown below −

Step 7 − Click on the Send button.

Response

Once a request has been sent, we can see the response code 200 OK populated in the Response body. 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 (673 ms) and payload size (705 B) are populated. The Response body shows the salary and age got updated to 2000 and 15 respectively for the employee having id 21.

raja
Published on 18-Nov-2021 12:51:04
Advertisements