0

I am getting HTTP error 422, while making a DELETE request using volley. But, I am able to success response when I make request on Postman. Also, when I tried with HTTPConnection again got the same error.

Here is my code of volley request

JsonObjectRequest jsonObjReq = new JsonObjectRequest(Method.DELETE, SERVER_URL,
postPropertyJSONObject, responseListener, errorListener);
Marcus M
  • 103
  • 5

1 Answers1

3

you can refer https://github.com/ngocchung/DeleteRequest for long term solution, as it looks from documentation, but I have not tested this. A quick work arrount is to, to make request as post and then overwrite the header X-HTTP-Method-Override as DELETE.

JsonObjectRequest jsonObjReq = new JsonObjectRequest(Method.POST, SERVER_URL,postPropertyJSONObject, responseListener, errorListener);

and then add Header like this

@Override
        public Map<String, String> getHeaders() throws AuthFailureError {
            Map<String, String>  headers = new HashMap<String, String> ();
            headers.put("X-HTTP-Method-Override", "DELETE");
            headers.put("Accept", "application/json");
            headers.put("Content-Type", "application/json");

            return headers;
        }
MSC
  • 422
  • 5
  • 14