Adarsh Yadav Adarsh Yadav - 1 year ago 155
Android Question

How to get Retrofit success responce status codes

I am not able to get success response status code from response like 200,201.. etc. As we can easily get error codes from

class like
. Is there any workaround for getting status codes?

jhm jhm
Answer Source

As per Retrofit 2.0.2, the call is now

public void onResponse(Call<YourModel> call, Response<YourModel> response) {
    if (response.code() == 200) {
       // Do awesome stuff
    } else {
       // Handle other response codes

Hope it helps someone :-)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download