HTTP Status codes for RESTFul Services

A good understanding of the HTTP protocol is crucial for a successful RESTful implementation. Although I know that REST is not dependent of HTTP, we all know that it’s the most common implementation.

Below I made a quick overview of HTTP status codes and the intent is to help during the development and test of REST services.

General HTTP Codes

1xx – Informational: Request received, continuing process.

2xx – Success: Action successfully received, understood, and accepted.

3xx – Redirection: Client must take additional action to complete the request.

4xx – Client Error: Request contains bad syntax or cannot be fulfilled.

5xx – Server Error: Server failed to fulfil an apparently valid request.

In the table below you have the description of the most common response codes:

Code Meaning Description
200

201

202

204

206

OK

Created

Accepted

No Content

Partial Content

– Successful HTTP request.

– New resource created.

– Accepted for processing, but not yet completed.

– Successfully processed, but no return content.

– Only part of the resource returned.

300

301

303

304

Multiple Choices

Moved Permanently

See Other

Not Modified

– Multiple options for the resource that the client may follow.
– This and all future requests should be directed to the given URI. 

– Response can be found at URI using GET method.

– Resource has not been modified since last requested

400

401

403

404

405

406

409

410

412

415

417

418

Bad Request

Unauthorized

Forbidden

Not Found

Method Not Allowed

Not Acceptable

Conflict

Gone

Precondition Failed

Unsupported Media Type

Expectation Failed

I’m a teapot

– Request contains bad syntax or cannot be fulfilled.- Request refused, when authentication is possible but has failed or not yet been provided.

– Request was legal, but the server refuses to respond to it.

– Resource could not be found but may be available again in the future.

– Request made using method not supported by that resource.

– Resource can only generate content not acceptable given Accept headers sent in.

– Request could not be processed due to conflict in the request.

– Resource no longer available and will not be available again.

– Server does not meet precondition put on the request.

– Request did not specify any media types the resource supports.

– Server cannot meet requirement of Expect header field.

– Response entity “MAY be short and stout”.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s