2017-04-18 93 views
0

錯誤: - 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); 

回答

0

這不是代碼錯誤。按照w3 .org等

401未授權 - 請求需要用戶認證

因此,它可能是錯誤的,因爲你是unaut。爲了訪問這個api而做了大量的調整檢查會話或密鑰。

相關問題