DEV Community

boxseb
boxseb

Posted on

Reminder about REST

GET

idempotent method to retrieve data out of API endpoint

200 returned when resource is found
404 returned when resource is not found
400 returned when a request is shaped incorrectly

POST

not idempotent creates new resource via API resource collection endpoint

201 should be returned containing created entity
200 or 204 returned when resource is created but cannot be identified by URI or returned in response body

PUT

used to update/replace resource addressed by resource identifier

200 or 204 returned to identify successful completion
201 returned when resource has been created
404 returned when resource not found

DELETE

used to delete resources addressed by resource identifier

200 returned when action has been performed and response contains status describing entity
202 returned when the action has been queued
204 returned when action has been performed but response does not contain status describing entity
404 returned when resource not found

PATCH

used to partially modify a resource

200 returned when action has been performed and response contains status describing entity
202 returned when the action has been queued
204 returned when action has been performed but response does not contain status describing entity
404 returned when resource not found

HEAD

used to find out based on response headers what response would be returned if GET method was used

Top comments (0)