retrofit + rxjava2报错java.lang.IllegalStateException:Excepted a String but was BEGIN_OBJECT at line..
原创
©著作权归作者所有:来自51CTO博客作者WongKyunban的原创作品,请联系作者获取转载授权,否则将追究法律责任
在使用retrofit和rxjava2进行网络请求:
//查询订单支付状态
@Headers({
"Content-Type:application/x-www-form-urlencoded",
"appId:android"
})
@GET("/tmi/trade/tradeStatus")
Observable<BaseResponseBody<String>> getStatus(@Query("orderId") String orderId, @Query("date")long date);
然后就报了如下的错误:
java.lang.IllegalStateException:Excepted a String but was BEGIN_OBJECT at line 1 column 43 path $.retEntity
期待返回值是String,但是服务器返回的是json字符串,把String改成相应的类名OK,如:
//查询订单支付状态
@Headers({
"Content-Type:application/x-www-form-urlencoded",
"appId:android"
})
@GET("/tmi/trade/tradeStatus")
Observable<BaseResponseBody<StatusBean>> getStatus(@Query("orderId") String orderId, @Query("date")long date);
谢谢阅读。