I am currently working on a Web service that provides a JSON-encoded payload. In the event of a failed service call, such as due to invalid parameters, an error will be returned in JSON format. I am uncertain about which HTTP status code is appropriate for this situation.
On one hand, it might make sense to return a 200 OK response since the actual HTTP transfer was successful, despite encountering an application error.
However, following a RESTful approach would suggest that if the caller is trying to post to a resource and the JSON parameters are found to be invalid, a 400 Bad Request status code would be more fitting.
My client-side implementation relies on Prototype, which offers a convenient way to handle callbacks based on HTTP status codes using onSuccess and onFailure. This makes me inclined to use status codes to indicate service success or failure, but I am open to hearing opinions or insights from others about common practices in this area.
Thank you!