Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: How to get the JSON object returned in case of an exception using RoboSpice

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!

like image 471
drginm Avatar asked Jun 22 '13 19:06

drginm


1 Answers

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.

like image 95
rciovati Avatar answered Nov 14 '22 23:11

rciovati