RESTful API cheatsheet

Status codes

200 OKSuccessful get, patch (return a JSON object)
201 CreatedSuccessful post (return a JSON object)
202 AcceptedSuccessful post, delete, path – async
204 No contentSuccessful delete
206 Partial contentSuccessful get – async

Error status

401 UnauthorizedNot authenticated
403 ForbiddenAuthenticated, but no permissions
422 Unprocessable entityValidation

Errors

HTTP/1.1 401 Unauthorized
Content-Type: application/json
{
  'id': 'auth_failed',
  'message': "You're not logged in."
}

Here’s an example of a possible error reply.

Versioning

GET /api/foo
Accept: application/json; version=1

You can pass a version=x to the Accept request header. Info here

Authentication

curl -is https://$TOKEN@api.service.com/

Methods

GET /articles/1read, returns 200
PUT /articles/1edit (or path), returns 200
DELETE /articles/1delete, returns 200
POST /articlescreate, returns 201
GET /articleslist, returns 200

References

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *