Any RESTafarians around?
I'm implementing a REST API and am wondering if there's a standard /
standard practice / strong opinion on what HTTP status codes map to
form validation errors when processing HTTP REST requests.
Say for example I have the following HTTP request:
POST /tags/rails/messages/
PARAMS: message[name]=hello&message[body]=this+is+my+first+message
HTTP-ACCEPT: text/html; ...
This is just like doing a POST submission from a "New Post" HTML
page. If there was a form validation error, e.g. a "blurb" parameter
is required, the web browser would normally just return a 200 OK and
the HTML page would show the error message.
200 OK
<html><body><p>The required field "blurb" was missing</p></body></html>
In the REST XML-based API I'd like to indicate the form validation
error via the relevant HTTP status code and HTTP response body.
POST /tags/rails/messages/
PARAMS: message[name]=hello&message[body]=this+is+my+first+message
HTTP-ACCEPT: application/xml; ...
400 Bad Request
<error>The parameter post[blurb] was not specified</error>
For creating a new resouce I'm thinking 403 Forbidden, or maybe 400
Bad Request?
For updating a resource I'm thinking 409 Conflict, or maybe 403 or 400?
Is there any convention or standard for this?
Also, the body of the error response could be more XML-like, as was
pondered in my blog post:
http://toolmantim.com/article/2006/8/30/
correct_http_status_codes_and_responses
Keen to know your thoughts.
-- tim
*******************************************************************
List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm
Help: [EMAIL PROTECTED]
*******************************************************************