For example, calling
api.getUserName(userId, new Callback() {...});
cause:
retrofit.RetrofitError: retrofit.
Here is what I did, after poking around in the debugger. Note: this is for actually getting it inside an error callback, not the success callback.
You'll see that the success type is found by calling retrofitError.getSuccessType()
and returns and object of type Type
You can then call retrofitError.getBodyAs(YourType.class)
which is all I needed to do because for me its always the class I expect it to be.
Here is the one-liner answer:
retrofitError.getBodyAs(retrofitError.getSuccessType())
Now, I'll note that I dont have to do anything like this regarding the success callback because it's already working magically.