我在我的API界面中获得了这个方法
@DELETE("/posts/{id}")
Call<Void> deletePost(@Path("id") int id);
但我打电话的方法面临失败:
mAPIService.deletePost(id ).enqueue(new Callback<Void>() {
@Override
public void onResponse(Call<Void> call, Response<Void> response) {
if(response.isSuccessful()) {
showResponse(response.body().toString());
Log.i("TAG", "post deleted to API." + response.body().toString());
}
}
@Override
public void onFailure(Call<Void> call, Throwable t) {
Log.e("TAG", "Unable to submit post to API.");
}
});
答案 0 :(得分:0)
使用Call<ResponseBody>
,而不是Call<Void>