Sobes.tech
Junior — Middle

What is the purpose of the HTTP PUT method in RESTful API?

sobes.tech AI

Answer from AI

The HTTP PUT method in RESTful API is used to create or replace a resource at the specified URI. Key characteristics of PUT:

  • Idempotency: repeated requests with the same data do not change the result after the first request.
  • Create or update: if the resource exists, it is updated; if not, it is created.
  • Full update: usually, PUT sends a complete representation of the resource, replacing the existing one.

Example: if you have a user resource at /users/123, a PUT request with a new JSON object will replace the data of user 123 with the new data.

Unlike POST, which is typically used for creating resources with the server generating an identifier, PUT explicitly specifies the URI of the resource.

What is the purpose of the HTTP PUT method in RESTful… - sobes.tech