I am using Robospice for Android with retrofit and OKHttp. Everything works great with responses submitted to the action using Robospice RequestListener. The problem is that it only returns a failure if the connection time or other network problem. If 401 returns, then it is classified as successful, but with a null response, since it cannot parse JSON in our POJO MobileAppSetup.
At the moment, I need to perform a null response check, but I do not know what the reason is if it was a server error or a valid 401.
public final class HTTPRequestListener implements RequestListener<MobileAppSetup> {
@Override
public void onRequestFailure(SpiceException spiceException) {
Log.d("", "failure:"+ spiceException);
loginProgress.hide();
}
@Override
public void onRequestSuccess(final MobileAppSetup response) {
Log.d("","success. Data: "+response);
if(response==null)
showDialog("Error logging in", "Please check your username and password and try again.", "");
loginProgress.hide();
postLoginProcess(response);
}
}
onRequestFailure, . , Robospice . , - , .