我正在使用改造来调用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()); } });
解决方法
原文地址:https://www.jb51.cc/android/315578.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。