【发布时间】: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