E /排球:[127] BasicNetwork.performRequest:意外的响应码401,用于
问题描述:
错误: - E /排球:[127] BasicNetwork.performRequest:意外的响应码401,用于E /排球:[127] BasicNetwork.performRequest:意外的响应码401,用于
如何解决这个错误? StringRequest stringRequest =新StringRequest(Request.Method.POST,URL_POST,新Response.Listener(){ @Override 公共无效onResponse(字符串响应){
try {
JSONObject msgjson = new JSONObject(response);
Log.d("aaaaa", String.valueOf(msgjson));
Log.d("aaa", "aaa");
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.d("aaa", "aaa");
Toast.makeText(MainActivity.this, "error", Toast.LENGTH_SHORT).show();
}
}) {
@Override
protected Map<String, String> getParams() throws AuthFailureError {
Map<String, String> params = new HashMap<String, String>();
String id = "524901";
String units = "metric";
String appid = "67aa03cd6bedc6f6fb6f9f506968f3d6";
params.put("id", id);
params.put("units", units);
params.put("appid", appid);
return params;
}
};
RequestQueue requestQueue = Volley.newRequestQueue(this);
requestQueue.add(stringRequest);