Rest WebService error handling.

Posted by Pratik on Stack Overflow See other posts from Stack Overflow or by Pratik
Published on 2009-08-24T14:23:05Z Indexed on 2010/04/15 12:13 UTC
Read the original article Hit count: 428

Filed under:
|

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!

© Stack Overflow or respective owner

Related posts about rest

Related posts about web-services