如何对不同类型的呼叫和响应机构进行改装?我有一个错误的限制。类型必须相同 <T> and <T>
. response bodie可以包含int value,但call不应该包含int value,因为当我用int value初始化callbody对象时,它已经包含n1=0,并将此参数发送到服务器。
@PUT("/api/test")
Call<CallBody> test1(@Body CallBody params_body);
public class CallBody {
public String id;
}
public class ResponceBody {
public String s1;
public int n1;
}
public void Test(String id) {
CallBody params_body = new CallBody();
params_body.id = id;
Call<CallBody> call1 = apiInterface.test1(params_body);
call1.enqueue(new Callback<CallBody>() {
@Override
public void onResponse(Call<CallBody> call, Response<ResponceBody> response) {
ResponceBody response = response.body();
}
@Override
public void onFailure(Call<CallBody> call, Throwable t) {
call.cancel();
}
});
}
1条答案
按热度按时间yftpprvb1#
尝试,