我是 Android 新手,我每天花 3 个小时来解决这个问题大约有一周时间,但我仍然找不到解决方案,我将从服务器获取对象列表并将它们传递给 Adapter 和另一个进程。但是我遇到了麻烦,没有错误,在我的Android Studio中我得到了“ response.code = 200 ”但是我的对象列表是空的,尽管在具有相同授权和相同用户名的邮递员中,对象列表不为空。我不知道我该怎么办,所以最后我不得不问我的问题。
首先我们来看看Postman
身体 : :
授权 : :
现在,当我单击 Postman 中的发送按钮时,我得到“代码:200”,听到的是响应正文:
{
"results": [
{
"_id": "5c7e69d283c0b00001108fad",
"count": 2,
"productId": "5ba51d877246b700016ec205",
"username": "rezash",
"createdAt": "2019-03-05T12:21:38.196UTC",
"updatedAt": "2019-03-05T12:36:11.058UTC",
"ACL": {
"*": {
"read": true,
"write": true
}
}
},
{
"_id": "5c7e69d483c0b00001108fae",
"count": 4,
"productId": "5acc0f2c790c0c000132c984",
"username": "rezash",
"createdAt": "2019-03-05T12:21:40.338UTC",
"updatedAt": "2019-03-05T12:36:15.830UTC",
"ACL": {
"*": {
"read": true,
"write": true
}
}
}
]
}
在我的 OnlineShopAPI 界面中:
public interface OnlineShopAPI {
String BASE_URL = "https://api.backtory.com/";
@Headers("X-Backtory-Object-Storage-Id:5a154d2fe4b03ffa0436a535")
@HTTP(method = "POST" , path = "object-storage/classes/query/Basket" , hasBody = true)
Call<MainBasketShopResponse> mainBasketShop (
@Header("Authorization") String authorization,
@Body BasketShop basketShop
);
interface getMainBasketShop {
void onResponse(List<BasketShop> basketShopList);
void onFailure(String cause);
}
}
我的 MainBasketShopResponse 类:
public class MainBasketShopResponse {
@SerializedName("results")
List<BasketShop> basketShopList;
public MainBasketShopResponse() {
}
湖上湖
相关分类