【问题标题】:How to make a PATCH request with jSONObjectRequest in android volley?如何在 android volley 中使用 jSONObjectRequest 发出 PATCH 请求?
【发布时间】:2016-08-31 00:29:59
【问题描述】:

我想使用 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";
            }

        });

【问题讨论】:

  • 你得到答案了吗?还是您尝试了其他方法?

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


【解决方案1】:

错误 405 表示此错误并非来自您的 JsonObjectRequest。可能是url、手机网络或者服务器造成的

【讨论】:

  • 好的。把它的工作放在邮递员身上。请告诉我如何解决它。 @马克沉
  • 我也不知道。您提供的信息不足以解决问题。
猜你喜欢
  • 2019-01-26
  • 2015-08-10
  • 1970-01-01
  • 2013-06-07
  • 1970-01-01
  • 2013-11-19
  • 2013-01-05
  • 1970-01-01
相关资源
最近更新 更多