Volley Post JsonObjectRequest ignoring parameters while using getHeader and getParams

前端 未结 2 2103
礼貌的吻别
礼貌的吻别 2020-12-09 11:48

I am trying to connect API url=\"api adress\" which accepts two header types application/json to reponce in json and application/xml to reponce in xml. I need to hit JSON wi

相关标签:
2条回答
  • 2020-12-09 12:48

    Volley will ignore your Content-Type setting, if you want to modify the content-type, you can override the getBodyContentType method :

    JsonObjectRequest jsonObjReq = new JsonObjectRequest(Method.POST, url,
            new JSONObject(params), response, response_error) {
        @Override
        public String getBodyContentType() {
            return "application/json; charset=utf-8";
        }
    }
    

    for why volley ignore your parameters? take a look at my another answer.

    0 讨论(0)
  • 2020-12-09 12:50

    Volley JsonObjectRequest Post request not working

    Take the other answer from that post wich starts with: You can create a custom JSONObjectReuqest

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