Java response.body().getResponseCode()==200-无响应
始终从服务器引发响应,即无效响应 我尝试了各种方法,但都没有反应。当我尝试GetCode200时,发生的是NPE 在我用同样的方法处理不同的案例之前,我可以得到一个回应。。。但在这种情况下,我没有注意到报告。而输入和后端在我看来是正确的。 我希望我的朋友能帮助我,谢谢 此函数用于获取响应postJava response.body().getResponseCode()==200-无响应,java,android,httpresponse,Java,Android,Httpresponse,始终从服务器引发响应,即无效响应 我尝试了各种方法,但都没有反应。当我尝试GetCode200时,发生的是NPE 在我用同样的方法处理不同的案例之前,我可以得到一个回应。。。但在这种情况下,我没有注意到报告。而输入和后端在我看来是正确的。 我希望我的朋友能帮助我,谢谢 此函数用于获取响应post HashMap<String, String> params = new HashMap<>(); params.put("id_member",s
HashMap<String, String> params = new HashMap<>();
params.put("id_member",sharedPrefManager.getSpIdMember() );
params.put("id_product_category", txt_id_product_category.getText().toString());
params.put("id_product", txt_id.getText().toString());
params.put("number", txt_number.getText().toString());
params.put("list_id_company", mitraStringBuilder.toString());
Call<ResponseCicilan> getCicilan = mApiService.getCicilanProduct(params);
getCicilan.enqueue(new Callback<ResponseCicilan>() {
@Override
public void onResponse(Call<ResponseCicilan> call, Response<ResponseCicilan> response) {
if(response.body()!=null){
ResponseCicilan responseCicilan = response.body();
String content ="";
if(response.body().getResponseCode()==200){
content+= responseCicilan.getData().getProductMeta().getIdProduct();
}else {
content+=responseCicilan.getMessage();
}
Log.d("jajal", "onResponse: login res"+content);
//
// Toast.makeText(TransactionSelectMitra.this, ""+response.message(), Toast.LENGTH_LONG).show();
// Log.d("bismillah", "onResponse: fail "+response.code());
// return;
}
Log.d("bismillah", "onResponse: success"+response.code()+" "+response);
if(response.body().getResponseCode()==200){
String content="";
// _loginButton.setEnabled(false);
ResponseCicilan responseCicilan = response.body();
content += "code:"+ response.code();
content += "token:"+ responseCicilan.getData().toString();
Log.d("bismillah", "onResponse: login res"+content);
} else {
Toast.makeText(TransactionSelectMitra.this, "Invalid response from server", Toast.LENGTH_SHORT).show();
}
}
@Override
public void onFailure(Call<ResponseCicilan> call, Throwable t) {
Toast.makeText(TransactionSelectMitra.this, "Invalid response from server", Toast.LENGTH_SHORT).show();
}
});
}
请将stacktrace@ScaryWombatthis响应的相关部分发布到控制台中。您可以从两个不同的位置打印出来,是哪一个?如果不是
200
,那么响应是什么?如果出现错误-错误是什么?根本没有响应@恐怖蝙蝠
@FormUrlEncoded
@POST("ApiMobile/getDatatenor")
Call<ResponseCicilan> getCicilanProduct(@FieldMap HashMap<String, String> params);
public class ResponseCicilan{
@SerializedName("response_code")
private int responseCode;
@SerializedName("data")
private Data data;
@SerializedName("message")
private String message;
public void setResponseCode(int responseCode){
this.responseCode = responseCode;
}
public int getResponseCode(){
return responseCode;
}
public void setData(Data data){
this.data = data;
}
public Data getData(){
return data;
}
public void setMessage(String message){
this.message = message;
}
public String getMessage(){
return message;
}
}