-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
您需要確認,在'url'正在處理'HTTP-POST'請求的服務器。也許編輯這個問題來包含請求處理服務器端,這樣我們都可以檢查並提出可能的解決方案。 – ishmaelMakitla
yes url正在處理httppost。 – Mayuri
我已經用普通的HttpPost進行了測試,並且從那裏開始工作,但在使用Volley時出現了錯誤。 – Mayuri