向截击PUT请求添加参数-Android

向截击PUT请求添加参数-Android,android,parameters,android-volley,put,Android,Parameters,Android Volley,Put,我一直在我的应用程序中使用截击库进行网络连接。我能够在GET和POST请求中附加参数,两者都可以正常工作,但无法在PUT请求中实现这一点。我总是收到一个“415-status{Unsupported media type}-result{Invalid content type}”错误。做了很多搜索,但都没有成功 这就是我尝试过的 RequestQueue requestQueue = VolleyRequests.getInstance().getRequestQueue(); Str

我一直在我的应用程序中使用截击库进行网络连接。我能够在GET和POST请求中附加参数,两者都可以正常工作,但无法在PUT请求中实现这一点。我总是收到一个“
415-status{Unsupported media type}-result{Invalid content type}
”错误。做了很多搜索,但都没有成功

这就是我尝试过的

RequestQueue requestQueue = VolleyRequests.getInstance().getRequestQueue();
    String uri = "https://myURI";
    StringRequest request = new StringRequest(Request.Method.PUT, uri, new Response.Listener<String>() {
        @Override
        public void onResponse(String response) {

            Log.d("server response",response);
            userCallBack.done(response);

        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {

        }
    }){
        @Override
        public Map<String, String> getHeaders() throws AuthFailureError {
            Map<String, String>  headers = new HashMap<String, String>();
            headers.put("secret_apikey", "xxxxxxx");
            headers.put("Content-Type", "application/json");
            headers.put("Cache-Control", "no-cache");
            headers.put("Accept", "application/json");
            return headers;
        }

        @Override
        protected Map<String, String> getParams() throws AuthFailureError {
            Map<String, String>  params = new HashMap<String, String>();
            params.put("userid", "013");

            params.put("sale_amount","2000");
            return params;
        }};
   requestQueue.add(request);

我不能用POST或get请求替换它,因为我调用的API只接受PUT请求。请提供帮助。

您是将其提交给您控制的web服务还是第三方?我看不出你在哪里执行请求。你能查一下那个网络服务的日志吗?我已经更新了代码。不,它不是我控制的web服务。还有其他想法吗??谢谢
 @Override
 public byte[] getBody() throws AuthFailureError {
            byte[] b = null;
            JSONObject obj = new JSONObject();
            try {
                obj.put("userid", "013");            
                obj.put("sale_amount","2000");
            } catch (JSONException e) {
                Log.d("Excep", String.valueOf(e));
            }
            try {
                Log.i("json", obj.toString());
                b = obj.toString().getBytes("UTF-8");
            } catch (UnsupportedEncodingException e) {
                Log.d("Excep", String.valueOf(e));
        }

            return b;
        }