.NET Core Web API- HTTP Status Codes


HTTP status codes are three-digit numbers that are returned by a server in response to a client's request. They provide information about the status of the request and help in understanding the outcome of the communication between the client and the server.

ASP.NET web API HTTP Status Code

Here are some common HTTP status codes and their meanings.

S.N. Code and Description
1 1xx: Informational

The server has received the initial part of the request, and the client can proceed with sending the rest of the request.

2 2xx: Success

This class of status codes indicates the action requested by the client was received, understood, and accepted.

3 3xx: Redirection

This class of status code indicates the client must take additional action to complete the request. Many of these status codes are used in URL redirection.

4 4xx: Client Error

This class of status code is intended for situations in which the error seems to have been caused by the client.

5 5xx: Server Error

It means the server failed to fulfill an apparently valid request.

HTTP status codes are extensible and HTTP applications are not required to understand the meaning of all the registered status codes. Given below is a list of all the status codes.

1xx: Information

Message Description
100 Continue The server has received the initial part of the request, and the client can proceed with sending the rest of the request.

2xx: Successful

Message Description
200 OK The request is OK. The request was successful, and the server has returned the requested resource.
201 Created

The request was successful, and a new resource was created as a result.

202 Accepted The request is accepted for processing, but the processing is not complete.
203 Non-authoritative Information The information in the entity header is from a local or third-party copy, not from the original server.
204 No Content The request was successful, but there is no content to return.
205 Reset Content The browser should clear the form used for this transaction for additional input.
206 Partial Content The server is returning partial data of the size requested. Used in response to a request specifying a Range header. The server must specify the range included in the response with the Content-Range header.

3xx: Redirection

Message Description
300 Multiple Choices A link list. The user can select a link and go to that location. Maximum five addresses.
301 Moved Permanently

The requested resource has been permanently moved to a new URI.

302 Found

The requested resource has been temporarily moved to a different URI.

303 See Other The client's cached version of the resource is still valid, and there is no need to retrieve it again.
304 Not Modified This is the response code to an If-Modified-Since or If-None-Match header, where the URL has not been modified since the specified date.
305 Use Proxy The requested URL must be accessed through the proxy mentioned in the Location header.
306 Unused This code was used in a previous version. It is no longer used, but the code is reserved.
307 Temporary Redirect

The requested resource is temporarily located at a different URI, and the client should make a new request to that URI.

308 Permanent Redirect

The requested resource is permanently located at a different URI, and the client should make future requests to that URI.

4xx: Client Error

Message Description
400 Bad Request The server could not understand the request due to malformed syntax or invalid parameters.
401 Unauthorized The client needs to authenticate itself to access the requested resource.
402 Payment Required You can not use this code yet.
403 Forbidden The server understands the request, but the client does not have access rights to the requested resource.
404 Not Found The requested resource could not be found on the server.
405 Method Not Allowed

The requested resource does not support the HTTP method used in the request.

406 Not Acceptable The request cannot be completed due to a conflict with the current state of the resource.
407 Proxy Authentication Required The client must authenticate itself with the proxy before the requested resource can be accessed.
408 Request Timeout The request took longer than the server was prepared to wait.
409 Conflict The request could not be completed because of a conflict.
410 Gone The requested resource is no longer available and will not be available again.
411 Length Required The Content-Length is not defined. The server will not accept the request without it .
412 Precondition Failed The pre condition given in the request evaluated to false by the server.
413 Request Entity Too Large The server will not accept the request, because the request entity is too large.
414 Request-url Too Long The server will not accept the request, because the url is too long. Occurs when you convert a "post" request to a "get" request with a long query information .
415 Unsupported Media Type The server refuses to accept the request because the media type of the request entity is not supported or not compatible with the resource.
416 Requested Range Not Satisfiable The requested byte range is not available and is out of bounds.
417 Expectation Failed The expectation given in an Expect request-header field could not be met by this server.

5xx: Server Error

Message Description
500 Internal Server Error The request was not completed. The server met an unexpected condition.
501 Not Implemented The request was not completed. The server did not support the functionality required.
502 Bad Gateway The server acting as a gateway or proxy received an invalid response from an upstream server.
503 Service Unavailable  The server is currently unable to handle the request due to temporary overload or maintenance
504 Gateway Timeout The server acting as a gateway or proxy did not receive a timely response from an upstream server.
505 HTTP Version Not Supported The server does not support the "http protocol" version.

Next