如何在android volley中使用jSONObjectRequest发出PATCH请求?

时间:2016-05-05 09:20:33

标签: java android android-fragments android-volley androidhttpclient

我想使用volley库在android中使用json对象请求发出PATCH请求。 它在邮递员工作,但当我在android中调用它时,它给我错误405,任何人有任何想法如何做到这一点?以下是我的代码:

requestQueue.add( new JsonObjectRequest(Request.Method.PATCH,url, jsonObject, new Response.Listener<JSONObject>() {
                    @Override
                    public void onResponse(JSONObject response) {

                        GiveCentralUtilities.setCurrentFragment(getActivity(),R.id.fragment_container,
                                SignUpPaymentInfo.newInstance(isSignup),SignUpPaymentInfo.TAG);


                        //  getAccessToken();

                    }
                }, this){
            @Override
            public Map<String, String> getHeaders() throws AuthFailureError {
                Map<String,String> header = new HashMap<String, String>();
                header.put("Authorization","Bearer "+GiveCentralUtilities.getPref(GiveCentralConstants.ACCESSTOKEN,getActivity()));
                header.put("Accept", "application/json");
                //  header.put("Content-Type", "application/json");
                System.out.println("vivekaccess"+GiveCentralUtilities.getPref(GiveCentralConstants.ACCESSTOKEN,getActivity()));

                return header;
            }


            @Override
            public String getBodyContentType() {
                return "application/json";
            }

        });

1 个答案:

答案 0 :(得分:0)

错误405表示此错误不是来自您的JsonObjectRequest。它可能是由网址,您的Android手机网络或服务器引起的