https://learn.microsoft.com/en-us/azure/architecture/best-practices/api-design https://www.restapitutorial.com/httpstatuscodes.html
Method | Example | Status Code |
---|---|---|
GET | /users/:id | 200 OK |
POST | /users | 201 Created |
PUT | /task/:name | New: 201 Create; Exists: 200 OK or 204 No Content |
PATCH | /user/:id | 2xx |
Examples
New User
POST /users { name: “Amar” } 201 Created Not idempotent - as new users created every time
Get User
GET /users/:id Idempotent
Upsert User
PUT /task/:name 201 Create if new, 200 OK or 204 NO CONTENT if exists Idempotent Complete representation of a resource
Modify some fields
PATCH /user/:id { name: “New name” }
Idempotent
Single request is the same as making multiple request. Only the state of the server is considered, not response code
HEAD, OPTIONS, GET, PUT, DELETE https://developer.mozilla.org/en-US/docs/Glossary/Idempotent