Retrofit: on failure status code return null pointer.

android, okhttp, retrofit

Solution

This is a bug. Add OkHttp's latest version to your dependencies.

compile 'com.squareup.okhttp:okhttp:2.0.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.0.0'

Problem

I am using Retrofit for my backend communication: If the status code is not 200 then the callback call failure method. But I want to get the status code inside the failure method for further code conditioning ``` @Override public void failure(RetrofitError retrofitError) { Logger.e("ERROR Status:", retrofitError.getResponse().getStatus() + ""); } } ``` But the above code always give a null pointer exception. How do i get the status code of my header on failure. Please help. Thanks in advance.

Original source