Machine-translated by Google. Questions are authored in English.
Top

Discussion

Which HTTP method is idempotent and used to update a resource ?

  • A.POST
  • B.GET
  • C.PUT
  • D.PATCH

Answer: C

The method is PUT.

PUT replaces the resource at the given URI with the representation sent. Sending the same PUT once or ten times leaves the resource in the same state, so it is idempotent by definition in the HTTP specification (RFC 9110). It is the standard method for updating a resource.

POST is not idempotent, since repeating it may create duplicates. GET is idempotent but only reads and never updates. PATCH applies a partial change and is not guaranteed to be idempotent, for example a patch meaning 'add 1 to the counter'.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.