[英]How to make a PATCH request with jSONObjectRequest in android volley?
我想使用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";
}
});
錯誤405表示此錯誤不是來自您的JsonObjectRequest。 它可能是由網址,Android手機的網絡或服務器引起的
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.