【发布时间】:2018-01-02 12:45:33
【问题描述】:
我想传递 2 个参数并通过 Retrofit 获取数据但是我在日志中关注 Response。
code...404 message...Not Found body...null
下面是我正在尝试的代码..
这是我的界面
public interface RequestInterface {
String NOTIFICATION_URL = "http://xxxxx/api/";
@GET("Image/GetNotificationList/{PageNumber}/{PageSize}")
Call<List<GetNotification>> getNotification(@Path("PageNumber") String PageNumber, @Path("PageSize") String PageSize);
}
当我拨打RequestInterface时
private void notificationJSON() {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(RequestInterface.NOTIFICATION_URL)
.addConverterFactory(GsonConverterFactory.create())
.build();
RequestInterface request = retrofit.create(RequestInterface.class);
Call<List<GetNotification>> call = request.getNotification("1","10");
call.enqueue(new Callback<List<GetNotification>>() {
@Override
public void onResponse(Call<List<GetNotification>> call, Response<List<GetNotification>> response) {
List<GetNotification> notification_pojo = response.body();
Log.d("Message", "code..."+response.code() + " message..." + response.message()+" body..."+response.body());
Log.d("Message pojo", "notification_pojo = " +notification_pojo);
}
@Override
public void onFailure(Call<List<GetNotification>> call, Throwable t) {
Log.e("onFailure ", t.getMessage());
}
});
这是我的Api Response
[
{
"PageUrl":"ureeee",
"CircularDetailId":1,
"Subject":"suBJECT",
"CircularPath":"/UploadDocument/3phasehindi.pdf",
"Description":"Description"
},
......
]
API 工作截图
【问题讨论】:
-
API 是否在 postman 中工作?
-
@R2R 不,它不起作用。
-
那是API的问题。请检查
-
你能更新工作屏幕截图吗
-
@R2R 请检查我已添加屏幕截图