Best practices
Hackernoon
Rester
CRUD
Create POST /resources 201 CREATED
Read GET /resources/{id} 200 OK
Update PUT /resources/{id} 200 OK
Remove DELETE /resources/{id} 205 NO CONTENT
Create
POST /resources
Content-type: application/json; charset=utf-8
Body: Resource to be created (all attributes, no id)
Constraints:
- id in body will be ignored, a new resource will be created instead
201 CREATED
Content-type: application/json; charset=utf-8
Body: Created resource (all attributes, with id)
Read
GET /resources/<id>
Constraints:
- resource with id must exist
200 OK
Content-type: application/json; charset=utf-8
Body: Found resource (all attributes, with id)
404 Not found
No content
Update
PUT /resources/<id>
Content-type: application/json; charset=utf-8
Body: Resource to be updated (all attributes, with id)
Constraints:
- resource with id must exist
- id in path must match id in request body
200 OK
Content-type: application/json; charset=utf-8
Body: Updated resource (all attributes, with id)
404 Not found
No content
Remove
DELETE /resources/<id>
Constraints:
- resource with id must exist
205 NO CONTENT
No content
404 Not found
No content