I am using the Retrofit library to do REST calls to a service I am using.
If I make an API call to my service and have a failure, the service returns a bit of JSON along with the standard HTTP error stuff. Using the RetrofitError
object included in the failure callback I am able to find the HTTP status code and several other things, however I am not able to retrieve the JSON that the service sends back.
For example, let's say I make a call to the API where I am trying to create a user. If the username already exists the service will return a 400 error code along with some JSON like this:
{"error":"Username already in use"}
Because a simple 400 error code isn't specific enough I really need access to the JSON that is returned.
Does anyone know how I can get at this JSON data? I have tried looking at every field in the RetrofitError
object and can't find it anywhere. Is there something additional I need to be doing?