Rest WebService error handling.
- by Pratik
Hi there,
I am using RestWebservice for few basic operations , like creating/searching. The request xml looks something like this
<customer>
<name/>
.....
</customer>
For a successful operation I return the same customer XML with extra fields populated in it(eg. systemId etc which we blank in the request) .
with Response.Status=2000
For an unsuccessful operation i return something like this with different error codes .
e.g Response.Status = 422(Unprocessable entity)
Response.Status= 500(Internal Server Error) and few others..
<errors>
<error> An exception occurred while creating the customer</error>
<error> blah argument is not valid.</error>
</errors>
Now i am not sure , whether this is the correct way of sending the errors to the client. Maybe it should be present in the header of the response.
I will really appreciate any help.
Thanks!