我正在使用Retrofit来调用android中的restful webservices,我遇到过这样的场景,比如我需要在改装请求中传递查询参数和请求有效负载对象,所以我尝试过这样的事情。
@POST("actual url")
Call<ReceiptList> getData(@Query("limit") String limit,
@Query("page") String page,
@Body ReceiptRequestPayload receiptRequestPayload);
调用API
Call<cutomObject> responseCall = API.getData("10", "1", requestPayload);
responseCall .enqueue(new Callback<cutomObject>() {
@Override
public void onResponse(Call<cutomObject> call, retrofit2.Response<cutomObject> response) {
Log.d(TAG, "onResponse: Receipts"+response);
Log.d(TAG, "onResponse: Receipts"+response.body());
}
@Override
public void onFailure(Call<ReceiptList> call, Throwable t) {
}
});
但它没有用。
提前致谢