Java POST方法截击错误的意外响应代码500
我在请求post方法中发现以下错误:post方法的意外响应代码500。 它工作正常,然后停止工作并开始显示此错误 这是我的发帖方法:Java POST方法截击错误的意外响应代码500,java,android,android-studio,post,android-volley,Java,Android,Android Studio,Post,Android Volley,我在请求post方法中发现以下错误:post方法的意外响应代码500。 它工作正常,然后停止工作并开始显示此错误 这是我的发帖方法: private void postRequest(String empresa, String matricula, String foto, String data, String face) { RequestQueue requestQueue=Volley.newRequestQueue(MainActivity.this);
private void postRequest(String empresa, String matricula, String foto, String data, String face) {
RequestQueue requestQueue=Volley.newRequestQueue(MainActivity.this);
String url="http://can't show the url";
StringRequest stringRequest = new StringRequest(Request.Method.POST, url, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
//análise de dados json
try {
JSONObject jsonObject = new JSONObject(response);
}
catch (Exception e){
e.printStackTrace();
// post_response_text.setText("POST DATA : unable to Parse Json");
}
Log.d("Response", response);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
// post_response_text.setText("Post Data : Response Failed");
Log.d("Error.Response", error.toString());
}
})
{
@Override
protected Map<String,String> getParams(){
Map<String,String> params=new HashMap<String, String>();
params.put("Id", "");
params.put("Empresa", empresa);
params.put("Matricula", matricula);
params.put("Foto", foto);
params.put("Data", data);
params.put("GPS", finalLatitude + "|" + finalLongitude);
params.put("idDispositivo", getIMEI());
params.put("arquivo", "");
params.put("face", face);
params.put("ip", getIP());
return params;
}
@Override
public Map<String,String> getHeaders() throws AuthFailureError {
Map<String,String> params=new HashMap<String, String>();
params.put("Content-Type","application/x-www-form-urlencoded");
return params;
}
};
stringRequest.setRetryPolicy(new DefaultRetryPolicy(
5000,
DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
requestQueue.add(stringRequest);
}
private void postRequest(字符串empresa、字符串矩阵、字符串foto、字符串数据、字符串面){
RequestQueue RequestQueue=Volley.newRequestQueue(MainActivity.this);
字符串url=”http://can“不显示url”;
StringRequest StringRequest=new StringRequest(Request.Method.POST,url,new Response.Listener()){
@凌驾
公共void onResponse(字符串响应){
//达多斯安阿利斯酒店
试一试{
JSONObject JSONObject=新JSONObject(响应);
}
捕获(例外e){
e、 printStackTrace();
//post_response_text.setText(“post数据:无法解析Json”);
}
Log.d(“响应”,响应);
}
},new Response.ErrorListener(){
@凌驾
公共无效onErrorResponse(截击错误){
//post_response_text.setText(“post数据:响应失败”);
Log.d(“Error.Response”,Error.toString());
}
})
{
@凌驾
受保护的映射getParams(){
Map params=新的HashMap();
参数put(“Id”,“Id”);
参数put(“Empresa”,Empresa);
参数put(“Matricula”,Matricula);
参数put(“Foto”,Foto);
参数put(“数据”,数据);
参数put(“GPS”,最终值+“|”+最终值);
参数put(“idDispositivo”,getIMEI());
参数put(“arquivo”和“);
参数放置(“面”,面);
参数put(“ip”,getIP());
返回参数;
}
@凌驾
公共映射getHeaders()引发AuthFailureError{
Map params=新的HashMap();
参数put(“内容类型”、“应用程序/x-www-form-urlencoded”);
返回参数;
}
};
stringRequest.setRetryPolicy(新的DefaultRetryPolicy(
5000,
DefaultRetryPolicy.DEFAULT\u最大重试次数,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
添加(stringRequest);
}
我试着在邮递员身上做了一个发帖请求,效果很好
我如何发送有关邮递员的信息: