Sobes.tech
Junior — Middle

Can you explain what is meant by an HTTP PUT method request?

sobes.tech AI

Answer from AI

The HTTP PUT method is used to create or replace a resource at a specified URL. Unlike POST, which typically creates a new resource, PUT is idempotent — repeated requests with the same data do not change the result.

Example of usage:

  • Update a user profile: send a PUT request with new data to the user's URL.

Example update request:

PUT /users/123 HTTP/1.1
Host: example.com
Content-Type: application/json

{
  "name": "Ivan Ivanov",
  "email": "ivan@example.com"
}

If the resource exists, it will be replaced; if not, it will be created.

Key features of PUT:

  • Idempotency
  • Complete replacement of the resource
  • Used for updating or creating at a known URL