Http status codes – quick reference

I am working on designing restful apis. Sometimes it is not easy to decide on what http status code to return for a condition. I went through restful standards on various sites and some of the commonly used restful apis and concluded with following commonly used status codes.

Status code Description
500 Any unexpected server-side error. Client is expected to retry.
200 Success is performing the action. Creation of a resource should use 201 instead
201 Success in creating a resource
301 Service requires https whereas the request was using http
401 Authentication failure – bad user name, bad password
404 Resource represented by the url of the request is not found
400 Bad request. Client should make some changes in the request and resend
403 Forbidden. Additional information should be sent to specify what is the recourse. The resource should exist, the client should have required auth.
402 Bad session id.
409 Client is creating a duplicate record. If an already existing resource id is passed in the request. It may also be sent if some of the fields violate any unique constraint on the resources
412 Some precondition for performing an action is missing. It could be absence of a header or some other criteria
413 Request entity too large
About these ads

About sachinshukla

I am working as a software developer for over a decade. I am presently employed with Yahoo
This entry was posted in Restful Api development and tagged , , , . Bookmark the permalink.

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