Http Status Code For Validation Error
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more http status code for invalid credentials about Stack Overflow the company Business Learn more about hiring developers or posting
Http Status Code For Login Failure
ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack rest http status codes best practices Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up What's an appropriate HTTP status code to return by a REST http status code for failed update API service for a validation failure? up vote 187 down vote favorite 54 I'm currently returning 401 Unauthorized whenever I encounter a validation failure in my Django/Piston based REST API application. Having had a look at the HTTP Status Code Registry I'm not convinced that this is an appropriate code for a validation failure, what do y'all recommend? 400 Bad Request 401 Unauthorized 403 Forbidden 405 Method Not Allowed
Http Status Code 422
406 Not Acceptable 412 Precondition Failed 417 Expectation Failed 422 Unprocessable Entity 424 Failed Dependency Update: "Validation failure" above means an application level data validation failure, i.e., incorrectly specified datetime, bogus email address etc. validation rest http-status-codes share|improve this question edited Dec 16 '13 at 2:58 George Stocker♦ 39.7k25132200 asked Dec 24 '09 at 22:34 michaeljoseph 2,62941720 1 Check out this answer: stackoverflow.com/a/2657624/221612 –Kenny Meyer Nov 26 '12 at 10:25 add a comment| 7 Answers 7 active oldest votes up vote 143 down vote accepted If "validation failure" means that there is some client error in the request, then use HTTP 400 (Bad Request). For instance if the URI is supposed to have an ISO-8601 date and you find that it's in the wrong format or refers to February 31st, then you would return an HTTP 400. Ditto if you expect well-formed XML in an entity body and it fails to parse. Note (1/2016): Over the last five years WebDAV's more specific HTTP 422 (Unprocessable Entity) has become a very reasonable alternative to HTTP 400. See for instance its use in JSON API Richardson and Ruby's RESTful Web Services contains a very helpful appendix on when to use the various HTTP response codes. The
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us http status code resource already exists Learn more about Stack Overflow the company Business Learn more about hiring developers rest status for whatsapp or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack
Rest Status Codes
Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up What's an appropriate HTTP status code to http://stackoverflow.com/questions/1959947/whats-an-appropriate-http-status-code-to-return-by-a-rest-api-service-for-a-val return by a REST API service for a validation failure? up vote 187 down vote favorite 54 I'm currently returning 401 Unauthorized whenever I encounter a validation failure in my Django/Piston based REST API application. Having had a look at the HTTP Status Code Registry I'm not convinced that this is an appropriate code for a validation failure, what do y'all recommend? 400 Bad Request 401 Unauthorized http://stackoverflow.com/questions/1959947/whats-an-appropriate-http-status-code-to-return-by-a-rest-api-service-for-a-val 403 Forbidden 405 Method Not Allowed 406 Not Acceptable 412 Precondition Failed 417 Expectation Failed 422 Unprocessable Entity 424 Failed Dependency Update: "Validation failure" above means an application level data validation failure, i.e., incorrectly specified datetime, bogus email address etc. validation rest http-status-codes share|improve this question edited Dec 16 '13 at 2:58 George Stocker♦ 39.7k25132200 asked Dec 24 '09 at 22:34 michaeljoseph 2,62941720 1 Check out this answer: stackoverflow.com/a/2657624/221612 –Kenny Meyer Nov 26 '12 at 10:25 add a comment| 7 Answers 7 active oldest votes up vote 143 down vote accepted If "validation failure" means that there is some client error in the request, then use HTTP 400 (Bad Request). For instance if the URI is supposed to have an ISO-8601 date and you find that it's in the wrong format or refers to February 31st, then you would return an HTTP 400. Ditto if you expect well-formed XML in an entity body and it fails to parse. Note (1/2016): Over the last five years WebDAV's more specific HTTP 422 (Unprocessable Entity) has become a very reasonable alternative to HTTP 400. See for instance its use in JSON API Richardson and Ruby's RESTful Web Services contains a very
consisting only of the Status-Line and optional headers, and is terminated by an empty line. There are no required headers http://www.restapitutorial.com/httpstatuscodes.html for this class of status code. Since HTTP/1.0 did not define any 1xx status codes, servers MUST NOT send a 1xx response to an HTTP/1.0 client except under experimental conditions. A https://cloud.google.com/storage/docs/json_api/v1/status-codes client MUST be prepared to accept one or more 1xx status responses prior to a regular response, even if the client does not expect a 100 (Continue) status message. Unexpected status code 1xx status responses MAY be ignored by a user agent. Proxies MUST forward 1xx responses, unless the connection between the proxy and its client has been closed, or unless the proxy itself requested the generation of the 1xx response. (For example, if a proxy adds a "Expect: 100-continue" field when it forwards a request, then it need not forward the http status code corresponding 100 (Continue) response(s).) Wikipedia Request received, continuing process. This class of status code indicates a provisional response, consisting only of the Status-Line and optional headers, and is terminated by an empty line. Since HTTP/1.0 did not define any 1xx status codes, servers must not send a 1xx response to an HTTP/1.0 client except under experimental conditions. 100 Continue The client SHOULD continue with its request. This interim response is used to inform the client that the initial part of the request has been received and has not yet been rejected by the server. The client SHOULD continue by sending the remainder of the request or, if the request has already been completed, ignore this response. The server MUST send a final response after the request has been completed. See section 8.2.3 for detailed discussion of the use and handling of this status code. Wikipedia This means that the server has received the request headers, and that the client should proceed to send the request body (in the case of a request for which a body needs to be sen