What's an appropriate HTTP status code to return by a REST API service for a validation failure?
Posted
by michaeljoseph
on Stack Overflow
See other posts from Stack Overflow
or by michaeljoseph
Published on 2009-12-24T22:34:52Z
Indexed on
2010/03/16
23:21 UTC
Read the original article
Hit count: 284
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
- 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 ie. incorrectly specified datetime, bogus email address etc.
© Stack Overflow or respective owner