I am using RoboSpice to access some rest services I developed using resteasy. I'm returning a JSON object when everything is ok and in the case of an exception I'm returning an http error code and a JSON object describing the nature of the exception. I'm able to get the JSON object when everything is working fine but I'm only able to get the exception and the http error code, but not the JSON I just returned in case of an exception. I have tried doing the same in iOS and I can get everything in every case, anyone knows how to do this using RoboSpice?. By the way I'm using Jackson and Spring. Thanks!
Asked
Active
Viewed 1,943 times
6
-
1This might help you: http://stackoverflow.com/questions/14864495/using-robospice-is-there-a-way-to-get-the-http-error-code-out-of-an-exception. Please note the `HttpClientErrorException.getResponseBodyAsString()`method – rciovati Jun 23 '13 at 10:07
-
You're right, rciovati!!! post it as an answer!!! thanks! – drginm Jun 23 '13 at 18:09
1 Answers
6
Take a look at the method explained in this thread for intercepting the http status for a failing request.
Please note that the HttpClientErrorException
has a getResponseBodyAsString()
method that should help you reading the JSON response.
-
1Thanks! This was a REALLY useful tip! Just to add my 2cents, I am using Gson on this returned string, to parse it in a similiar way to how Robospice automatically parses json to POJOs. – Janis Peisenieks Nov 25 '14 at 13:30