我正在使用改造来调用Web服务并且改造失败,来自’Throwable`的消息给了我
java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $
我假设这是因为.Net Web服务抛出错误而不返回JSON.但为了证明这一点,我需要能够在onFailure中看到原始响应.无论如何我能做到吗?
这是我正在使用的代码
public void userLoginRequestEvent(final AuthenticateUserEvent event) { Call call = sApi.login(event.getUsername(),event.getPassword(),OS_TYPE,DeviceInfoUtils.getDeviceName()); call.enqueue(new Callback<LoggedInUser>() { @Override public void onResponse(Response<LoggedInUser> response,Retrofit retrofit) { // response.isSuccess() is true if the response code is 2xx if (response.isSuccess()) { LoggedInUser user = response.body(); AppBus.getInstance() .post(new UserIsAuthenticatedEvent(user,event.getUsername(),event.getPassword())); } else { int statusCode = response.code(); // handle request errors yourself } } @Override public void onFailure(Throwable t) { // handle execution failures like no internet connectivity Log.d("ERROR",t.getMessage()); } });