REST: GET, POST, PUT, PATCH and idempotency
Answer out loud or in your head first, then compare.
Answer
GET reads a representation; POST is used to create a resource or perform an operation, among other things; PUT sets or replaces the representation at a given address; PATCH describes a partial change.
Idempotency: sending the same request several times has the same intended effect on the server as sending it once. GET, PUT and DELETE have this semantics. POST and PATCH are not automatically idempotent.
Example: retrying a payment request requires an idempotency key and handling on the server.
Pitfall: idempotency doesn't guarantee an identical response status. A repeated DELETE can return 404 even though the resource stays deleted.
How did it go? Be honest — “Not yet” puts the question on your review list.
Related questions
- D-P04 · What are HTTP methods and statuses for? — Backend, data and system design
- D-P15 · What is idempotency? — Backend, data and system design
- Which HTTP methods are idempotent? — General Web