2016-08-05 131 views
-2
JsonObjectRequest jsonRequest = new JsonObjectRequest(Request.Method.POST,url , jsonobj, 
       new Response.Listener<JSONObject>() { 
        @Override 
        public void onResponse(JSONObject respStr) { 
        if (respStr != null) { 
         //// some code 
}}}; 
new Response.ErrorListener() {`` 
        @Override 
        public void onErrorResponse(VolleyError error) { 
         pDialog.dismiss(); 
         Toast.makeText(CodeActivity.this, "Network Error", Toast.LENGTH_LONG).show(); 
        } 
       }) { 
      @Override 
      public Map<String, String> getHeaders() throws AuthFailureError { 
       Map<String, String> params = new HashMap<String, String>(); 

       params.put("Authorization", "Bearer " + token); 
       return params; 
      } 
     }; 
     RequestQueue requestQueue = Volley.newRequestQueue(this); 
     requestQueue.add(jsonRequest);` 

} 

我的logcat中有這個錯誤。 BasicNetwork.performRequest:URL 的意外響應代碼405我使用Volley發送請求。Volley:BasicNetwork.performRequest:使用POST製作JsonObjectRequest時意外的響應代碼405

+0

您需要確認,在'url'正在處理'HTTP-POST'請求​​的服務器。也許編輯這個問題來包含請求處理服務器端,這樣我們都可以檢查並提出可能的解決方案。 – ishmaelMakitla

+0

yes url正在處理httppost。 – Mayuri

+0

我已經用普通的HttpPost進行了測試,並且從那裏開始工作,但在使用Volley時出現了錯誤。 – Mayuri

回答

0

405不允許的方法

的請求方法不支持所請求的資源;例如,需要通過POST呈現數據的表單上的GET請求,或只讀資源上的PUT請求。

檢查Request.Method.POST允許服務器您嘗試使用

相關問題