Monday, May 18, 2015

Rest Http Status Code, Header (Request-Response)

HTTP codes used in Rest:
Http Response Code HTTP Method Response Body Contents Response code Description
200 GET, PUT, DELETE Resource No error, operation successful.
201 Created POST Resource that was created Successful creation of a resource.
202 Accepted POST, PUT, DELETE N/A The request was received.
204 No Content GET, PUT, DELETE N/A The request was processed successfully, but no response body is needed.
301 Moved Permanently GET XHTML with link Resource has moved.
303 See Other GET XHTML with link Redirection.
304 Not Modified conditional GET N/A Resource has not been modified.
400 Bad Request GET, POST, PUT, DELETE Error Message Malformed syntax or a bad query.
401 Unauthorized GET, POST, PUT, DELETE Error Message Action requires user authentication.
403 Forbidden GET, POST, PUT, DELETE Error Message Authentication failure or invalid Application ID.
404 Not Found GET, POST, PUT, DELETE Error Message Resource not found.
405 Not Allowed GET, POST, PUT, DELETE Error Message Method not allowed on resource.
406 Not Acceptable GET Error Message Requested representation not available for the resource.
408 Request Timeout GET, POST Error Message Request has timed out.
409 Resource Conflict PUT, PUT, DELETE Error Message State of the resource doesn't permit request.
410 Gone GET, PUT Error Message The URI used to refer to a resource.
411 Length Required POST, PUT Error Message The server needs to know the size of the entity body and it should be specified in the Content Length header.
412 Precondition failed GET Error Message Operation not completed because preconditions were not met.
413 Request Entity Too Large POST, PUT Error Message The representation was too large for the server to handle.
414 Request URI too long POST, PUT Error Message The URI has more than 2k characters.
415 Unsupported Type POST, PUT Error Message Representation not supported for the resource.
416 Requested Range Not Satisfiable GET Error Message Requested range not satisfiable.
500 Server Error GET, POST, PUT Error Message Internal server error.
501 Not Implemented POST, PUT, DELETE Error Message Requested HTTP operation not supported.
502 Bad Gateway GET, POST, PUT, DELETE Error Message Backend service failure (data store failure).
505 GET Error Message HTTP version not supported.

Request header in Rest:
Request Header Description
Accept Request a particular content type. Valid values: application/json, application/xml.
Accept-Encoding Request content encoding such as gzip.
Accept-Language Request a particular language. Supported where localized strings are generated, such as Updates event descriptions. Affects sort order. The lang query parameter will override this header.
Authorization Include appropriate authorization token.
Host Formats the host portion of embedded links to other social data.
If-Modified-Since Conditional GET.
If-Unmodified-Since Conditional GET.

Response header in Rest:

Response Header Description
Content-Encoding Included if content has been encoded (gzip).
Content-Language Language selected.
Content-Length. Size of response, in bytes, unless content or transfer encoding has been applied.
Content-Type Type of response.
Last-Modified The last time the resource data was modified.
Location URI of a newly created resources.
Transfer-Encoding The form of encoding used to transfer the entity to the user.

Sources: google,yahoo

No comments:

Post a Comment