question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Content-Type header is getting overridden

See original GitHub issue

I need to pass Content-Type : application/x-www-form-urlencoded; charset=UTF-8

as the header. But when I try the following way

        AndroidNetworking
            .post(Url.BASE_URL + requestPath)
            .addHeaders("Content-Type", "application/x-www-form-urlencoded; charset=utf-8")
            .setContentType("application/x-www-form-urlencoded; charset=utf-8")
            .addBodyParameter(requestPath.split("/").last(), jsonString)
            .setPriority(Priority.MEDIUM)
            .build()
            .getAsJSONObject(jsonObjectRequestListener)

its setting the header as Content-Type: application/x-www-form-urlencoded

and charset=UTF-8 is getting removed. How to forcefully add this complete thing as header ?

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Elswahcommented, Jul 18, 2019
AndroidNetworking.post("https://fierce-cove-29863.herokuapp.com/createAnUser")
                 .addBodyParameter("firstname", "Amit")
                 .addBodyParameter("lastname", "Shekhar")
                 .setContentType("application/json; charset=utf-8") // custom ContentType
                 .setPriority(Priority.MEDIUM)
                 .build()
                 .getAsJSONArray(new JSONArrayRequestListener() {
                    @Override
                    public void onResponse(JSONArray response) {
                      // do anything with response
                    }
                    @Override
                    public void onError(ANError error) {
                      // handle error
                    }
                });

this is the only way to send content type when iam trying to send application/x-www-form-urlencoded in addheader method not working i want to send it in add header how to do that. i dont want to use method setContentType i want to make this in AddHeader method only.

0reactions
ourdex86commented, Sep 3, 2019

@amitshekhariitbhu … Sorry by mistake it was closed. Any update on this ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

content-type header being overwritten during POST request
It is only when I do the POST request from my web service that the content-type is being overriden at the time of...
Read more >
Content-Type getting overwritten? · Issue #532 · libcpr/cpr
I'm experiencing a strange problem where for some requests, not all, if I set the content-type header explicitly it seems to be ignored...
Read more >
How can I override the http content-type header that the ...
Information · Open the WS CM job definition · Navigate to the Variables table (or click on the Autoedit tab if version 7...
Read more >
Impossible to override Content-Type header? - Google Groups
In my case I generate a HEAD handler automatically if there is a GET handler. I think for HEAD requests, there should be...
Read more >
FAQ: Can you override Content-Type header as part of Rest ...
​This is currently​ not possible. This is a known issue where trying to override the Content-Type header in the Rest Consumer transformation ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found