All HTTP Response Status Codes

Author: neptune | 18th-Dec-2022 | Views: 86
#API #Postman

HTTP response status codes indicate whether a specific HTTP request has been successfully completed. 

Responses are grouped in five classes:

1. Informational responses (100 – 199)

2. Successful responses (200 – 299)

3. Redirection messages (300 – 399)

4. Client error responses (400 – 499)

5. Server error responses (500 – 599)

adds

1. Informational responses (100 – 199)

a. 100
Response indicates that the client should continue the request or ignore the response if the request is already finished.

b. 101
Response to an Upgrade request header from the client and indicates the protocol the server is switching to.

c. 102

Response code indicates that the server has received and is processing the request, but no response is available yet.

d. 103
Response code primarily intended to be used with the Link header, letting the user agent start preloading resources while the server prepares a response.

adds

2. Successful responses (200 – 299)

a. 200 (Ok)

The request succeeded which means "success" depends on the HTTP method:

  • GET: The resource has been fetched and transmitted in the message body.

  • HEAD: The representation headers are included in the response without any message body.

  • PUT or POST: The resource describing the result of the action is transmitted in the message body.

  • TRACE: The message body contains the request message as received by the server.

adds


b. 201 (Created)

The request succeeded, and a new resource was created as a result. This is typically the response sent after POST requests, or some PUT requests.

c. 202 (Accepted)
The request has been received but not yet acted upon. It is intended for cases where another process or server handles the request, or for batch processing.

d. 203 (Non-Authoritative Information)

This response code means the returned metadata is not exactly the same, but is collected from a local or a third-party copy. Except for that specific case, the 200 OK response is preferred to this status.

adds

e. 204 (No content)
There is no content to send for this request, but the headers may be useful. The user agent may update its cached headers for this resource with the new ones.

f. 205 (Reset content)
Tells the user agent to reset content of the document which sent this request.

g. 206 (Partial content)
This response code is used when the Range header is sent from the client to request only part/partial content of a resource.

adds

3. Redirection messages (300 – 399)
a. 300 (Multiple Choices)
The request has more than one possible response. The user agent or user should choose one of them.

b. 301 (Moved Permanently)
The URL of the requested resource has been changed permanently. The new URL is given in the response.

c. 302 (Found)
This response code means that the URI of requested resource has been changed temporarily. Further changes in the URI might be made in the future. Therefore, this same URI should be used by the client in future requests.

d. 303 (see other)
The server sent this response to direct the client to get the requested resource at another URI with a GET request.

adds

4. Client error responses (400 – 499)

a. 400 (Bad Request)

The server cannot or will not process the request due to something that is perceived to be a client side error that include malformed request syntax, invalid request message framing, or deceptive request routing.


b. 401 (Unauthorized)

Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". That is, the client must authenticate itself to get the requested response.


c. 402 (Payment Required) 

This response code is reserved for future use. The initial aim for creating this code was using it for digital payment systems, however this status code is used very rarely and no standard convention exists.

adds


d. 403 (Forbidden)

The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401 Unauthorized, the client's identity is known to the server.


e. 404 (Not Found)

The server cannot find the requested resource. In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but the resource itself does not exist. 

Servers may also send this response instead of 403 Forbidden to hide the existence of a resource from an unauthorized client. This response code is probably the most well known due to its frequent occurrence on the web.

adds

5. Server error responses (500 – 599)

a. 500 (Internal Server Error)

The server has encountered a situation it does not know how to handle.

b. 501 (Not Implemented)

The request method is not supported by the server and cannot be handled. The only methods that servers are required to support (and therefore that must not return this code) are GET and HEAD.

c. 502 (Bad Gateway)

This error response means that the server, while working as a gateway to get a response needed to handle the request, got an invalid response.

adds

d. 503 (Service Unavailable)

The server is not ready to handle the request. Common causes are a server that is down for maintenance or that is overloaded. e. 504 (Gateway Timeout)

This error response is given when the server is acting as a gateway and cannot get a response in time.

f. 505 (HTTP Version Not Supported)

The HTTP version used in the request is not supported by the server.


Questions always asked in interview for these response status.




Related Blogs
Architecture of API Gateway
Author: neptune | 15th-Nov-2022 | Views: 539
#API #Microservice
Creating an API starts with the publisher, where it will be designed, and it will be published to the store for the consumer to explore and subscribe...

Introduction to API Gateway
Author: neptune | 14th-Nov-2022 | Views: 306
#API #Microservice
Application Programming Interface (API) is a business capability delivered over the internet, to internal or external consumers...

Why API Authentication?
Author: neptune | 01st-Jan-2023 | Views: 73
#API
API's play a vital role in linking applications to exchange services and data. There are a variety of ways to authenticate API requests...

View More