Introduction
A PUT request updates or replaces data on a server. It helps keep information current.
A PUT request updates or replaces data on a server. It helps keep information current.
PUT /resource/identifier HTTP/1.1 Host: example.com Content-Type: application/json { "key": "value", "another_key": "another_value" }
The URL includes the resource identifier to specify what to update.
The request body contains the new data to replace the old resource.
PUT /users/123 HTTP/1.1 Host: api.example.com Content-Type: application/json { "name": "Alice", "email": "alice@example.com" }
PUT /products/456 HTTP/1.1 Host: api.example.com Content-Type: application/json { "name": "New Product", "price": 19.99 }
This example updates the todo item with ID 1 to new details.
PUT /todos/1 HTTP/1.1 Host: jsonplaceholder.typicode.com Content-Type: application/json { "userId": 1, "title": "Buy groceries", "completed": false }
PUT replaces the entire resource; partial updates need PATCH.
Always include Content-Type header when sending JSON data.
Check server response to confirm update success (usually 200 or 204 status).
PUT requests update or replace existing data on the server.
They require the full new data in the request body.
Use PUT when you want to set a resource to a specific state.
PUT request in Postman?{
"id": 101,
"name": "Coffee Mug",
"price": 12.99
}
If the server replaces the entire product resource with this data, what will be the product's name after the update?id, name, email, and phone. You only want to change the phone number. What is the best practice to avoid accidentally deleting other fields?Pass the test and this pattern moves unknown