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
Using this you can get the error body
if (response != null && response.errorBody() != null) { JSONObject jsonObject = new JSONObject(response.errorBody().string()); String error = jsonObject.getString("error"); }