Reputation: 41939
Let's say I have a REST POST end-point: www.foo.com/validate/X
where X represents a number.
My server-side pseudocode looks like this:
validateId(id, jsonObj) {
if ( isValid(jsonObj) { return 200/OK }
else { return ??? }
}
What's the right HTTP return code here for the else
case? Basically I want to indicate to the client that its jsonObj
is not valid.
Upvotes: 2
Views: 13550
Reputation: 41938
If you don't care about using WebDAV codes, 422 Unprocessable Entity
is the most adequate, otherwise, use 400 Bad Request
.
Upvotes: 2
Reputation: 357
Usually for validating an input we have to use 400 (Bad Request) and your validation text( if the input wrong). You can read about in RESTful Web Services or other REST books.
Upvotes: 1