Volley Content-Type header not updating

前端 未结 1 1159
余生分开走
余生分开走 2020-12-06 02:55

I am trying to write a POST call in Volley, to send an XML body to the server. I cannot set the Content-Type header correctly.

The basic StringReq

相关标签:
1条回答
  • 2020-12-06 03:55

    The Content-Type header is not treated the same way as other headers by Volley. In particular, overriding getHeaders() to change the content type does not always work.

    The correct way to do this is to override getBodyContentType():

        public String getBodyContentType()
        {
            return "application/xml";
        }
    

    I found this by looking at the code for the JsonRequest class.

    Delyan also mentions it in his answer to this related question:

    • how to execute PUT request in Android Volley?
    0 讨论(0)
提交回复
热议问题