0

What status code should I set if validation of an object fails in a POST. Using Rest.

3 Answers 3

5

400 Bad request - http://restpatterns.org/HTTP_Status_Codes

see also: REST HTTP status codes for failed validation or invalid duplicate

Sign up to request clarification or add additional context in comments.

1 Comment

return 400 and add an additional response body like: <errors> <error> <code>1</code> <description>name must not be empty</description> </error> </errors> or something like that
1

The most appropriate one would probably be 400, "Bad Request." The 4xx status codes correspond to client errors.

Comments

1

422 comes to mind (see http://greenbytes.de/tech/webdav/rfc4918.html#STATUS_422)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.