HTTP status code for bad data

What HTTP status code should I return when a client sends bad data (for example, a string when an integer was expected)?

I used 400 Bad Request, but when I read over HTTP documents that are more applicable to HTTP protocol errors.

I would like to use a status code so that Flash and AJAX clients can distinguish between successful, bad data and server error without analyzing the response.

+31
Sep 01 '09 at 20:39
source share
2 answers

This is what 400 is for. Yes, it was used for poor use of the HTTP protocol, but not exclusively for that purpose.

+45
Sep 01 '09 at 20:43
source
β€” -

I would really be more inclined to catch bad data in the browser when the client clicks the submit button.

If not, then I will return 400, because, as the standard says:

The request could not be understood by the server due to incorrect syntax. The client SHOULD NOT repeat the request unchanged.

+5
Sep 01 '09 at 20:44
source



All Articles