What’s an appropriate HTTP status code to return by a REST API service for a validation failure?

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, i.e., incorrectly specified datetime, bogus email address etc.

9 Answers
9

Leave a Comment