Android Volley Post Request Header not changing

后端 未结 2 1393
温柔的废话
温柔的废话 2020-12-22 01:20

I am using Android Volley library to send POST request. And for POST request

  • Header is Content-Type:application/js
相关标签:
2条回答
  • 2020-12-22 01:48

    I found I had to override getBodyContentType() in order to get the Content-Type header to update correctly:

        public String getBodyContentType()
        {
            return "application/json; charset=utf-8";
        }
    

    Here is my question with some more details on this issue:

    • Volley Content-Type header not updating
    0 讨论(0)
  • 2020-12-22 02:05

    Using network sniffing tool like Wireshark,I found that my error lay on wrong HTTP header. Then using Chrome DHC plugin

    I found that Header Content-Type should be application/json; charset=utf-8and I was continuously using

        Map<String, String> header = new HashMap<String, String>();
        header.put("Content-Type", "application/json");
    

    instead of

        Map<String, String> header = new HashMap<String, String>();
        header.put("Content-Type", "application/json; charset=utf-8");
    

    Using proper Header solved my issue

    0 讨论(0)
提交回复
热议问题