Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

how to convert errorBody to pojo in retrofit

if (response.isSuccessful()) {
    // Do your success stuff...

} else {
    APIError message = new Gson().fromJson(response.errorBody().charStream(), APIError.class);
    Toast.makeText(MainActivity.this, "" + message.getMessage(), Toast.LENGTH_SHORT).show();
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #convert #errorBody #pojo #retrofit
ADD COMMENT
Topic
Name
6+3 =