title: Send a DELETE Request using Volley (Android) to a REST Api with parameters?
body: <p>How do I send a DELETE Request using Volley (Android) to a REST Api with parameters like access_token and username. I have tried almost everything on Internet but still I am getting a 400 error Message.
  I have tried sending the same DELETE request using PostMan and it works perfectly fine.</p>
  
  <p><strong>Here is the Error:</strong>
  E/Volley﹕ [1112] BasicNetwork.performRequest: Unexpected response code 400 for <a href="http://myserverip/messages/2" rel="nofollow">http://myserverip/messages/2</a></p>
  
  <p><strong>and Here is the Java code that I am using:</strong></p>
  
  <pre><code>String URI = "http://myserverip/messages/2";
  
  JsonObjectRequest request = new  JsonObjectRequest(Request.Method.DELETE,URI,null,
                                      new Response.Listener&lt;JSONObject&gt;() {
                                          @Override
                                          public void onResponse(JSONObject response) {
  
  Toast.makeText(contextm,response.toString(),Toast.LENGTH_SHORT).show();
  
                                          }
                                      },
                                      new Response.ErrorListener() {
                                          @Override
                                          public void onErrorResponse(VolleyError error) {
  
  
                                          }
  
  
                                      }){
  
                                  @Override
                                  public Map&lt;String, String&gt; getHeaders() throws AuthFailureError {
                                      Map&lt;String, String&gt; headers = super.getHeaders();
  
                                      if (headers == null
                                              || headers.equals(Collections.emptyMap())) {
                                          headers = new HashMap&lt;String, String&gt;();
                                      }
  
                                      headers.put("access_token", "access_token");
                                      headers.put("username", "username");
  
  
                                      return headers;
                                  }
                              };
  
                              MyApp.getInstance().addToRequestQueue(request);
  </code></pre>
  
  <p>Might not be really useful but here is the working DELETE request preview from <strong>PostMan</strong></p>
  
  <ul>
  <li>DELETE /messages/1 HTTP/1.1 </li>
  <li>Host: serveripaddress</li>
  <li>Cache-Control:no-cache</li>
  <li><p>Content-Type: application/x-www-form-urlencoded</p>
  
  <p>access_token=SPAVYaJ7ea7LzdeQYrBTsIRssuGbVpJI8G9XSV0n&amp;username=whit3hawks</p></li>
  </ul>