2

I'm using StringRequest to send HTTP POST request on my Android app. One of the POST requests returns HTTP 400 when it is triggered via Volley. The API returns HTTP 200 when it is triggered through rest clients(Postman, curl). I suspect there is something wrong in the request body sent through volley.

protected Map<String, String> getParams() 
    {  
            Map<String, String>  params = new HashMap<String, String>();  
            params.put("name", "Pomen Pogo");
            params.put("email", "pomen.pogo@staples.net");
            params.put("type", "Ninja");

            return params;  
    }

Is there any way to log the full request body that volley sends in the POST request? I've enabled VolleyLog.DEBUG = true;, It do logs the full response but It's is NOT logging the request body or URL.

Please help me to log the HTTP request details(url, request body etc.) in Volley.

Master Po
  • 1,497
  • 1
  • 23
  • 42
  • Please put your entire network code and the code from the serve side. So that I can test it. – Basu May 24 '17 at 18:26
  • @BasuSingh Sorry, I can't disclose the API (Its a 3rd party API to which I need to POST the data). Can you please share how can I print the request body in Volley? – Master Po May 24 '17 at 18:29
  • Post your Postman screenshot. Try using `getBody` instead of `getParams` also. You can refer my answer at https://stackoverflow.com/questions/33573803/how-to-send-a-post-request-using-volley-with-string-body/33578202#33578202 (`parseNetworkResponse` can be ignored because it's for the 2nd requirement of that OP) – BNK May 25 '17 at 04:02

1 Answers1

-4

Did you try the following?

Log.i(TAG, "Request body: " + new String(request.getBody()));
Samo
  • 2,093
  • 1
  • 17
  • 18