(most recent on top)
Response codes and bodies
204s are mostly for deletes. since posts usually return 201s and both puts and gets return bodies on the responses
β Nuno Marques
Verbs, their meaning and usage
- HTTP Methods for RESTful Services
- Representational state transfer - Wikipedia
- HTTP/1.1: Method Definitions
- REST β CRUD
β¦ POST = Create
# Entire Collection e.g. /customers
201 Created
'Location' header with link to /customers/{id} containing the new ID
# Specific Item e.g. /customers/{id}
404 Not Found
409 Conflict β if resource already exists
β¦ GET = Read
# Entire Collection e.g. /customers
200 OK
List of customers (use pagination, sorting and filtering on big lists)
# Specific Item e.g. /customers/{id}
200 OK β single customer
404 Not Found β if ID not found or invalid
β¦ PUT = Update / Replace
# Entire Collection e.g. /customers
404 Not Found β unless you want to update/replace every resource in the entire collection
# Specific Item e.g. /customers/{id}
200 OK
201 Created β if using PUT for create, no need for a Location header
204 No Content
404 Not Found β if ID not found or invalid
β¦ PATCH = Update / Modify
# Entire Collection e.g. /customers
404 Not Found β unless you want to modify the collection itself
# Specific Item e.g. /customers/{id}
200 OK
204 No Content
404 Not Found β if ID not found or invalid
β¦ DELETE = Delete
# Entire Collection e.g. /customers
404 Not Found β unless you want to delete the whole collection
# Specific Item e.g. /customers/{id}
200 OK β maybe along with a response body if describing the status
202 Accepted β if the action has not yet been enacted
204 No Content β with no response body
404 Not Found β if ID not found or invalid