我正在尝试使用改造从服务器获取响应。
仅显示原始响应:
Response{protocol=http/1.1, code=200, message=OK, url=http://********/GetData}
请求代码:
Call<ResponsePOJO> call1 = apiInterface.sendField(requestPojo);
call1.enqueue(new Callback<ResponsePOJO>()
{
@Override
public void onResponse(Call<ResponsePOJO> call,Response<ResponsePOJO> response)
{
ResponsePOJO responsePOJO=response.body();
}
@Override
public void onFailure(Call<ResponsePOJO> call, Throwable t) {
call.cancel();
}
});
@POST("/GetData")
@Headers("Content-Type: application/json")
Call<ResponsePOJO> sendField(@Body RequestPojo requestPojo);
gradle文件
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
如何获得json响应?