java – How to clear and/or set headers in com.google.api.client.http.HttpRequest for Content-Type – Stack Overflow
I am executing a post request using com.google.api.client.http.HttpRequest.
The server I am targeting has a problem with the content type
"application/json; charset=UTF-8"
which is what the google http api is setting. The target server is expecting
"application/json;charset=UTF-8"
In other words the target server cannot deal with the whitespace after the ;.
If I do
request.getHeaders().setContentType("application/json;charset=UTF-8")
or
request.getHeaders().set("Content-Type", "application/json;charset=UTF-8")
my settings go into a list, and then the api sets the headers itself, add those settings go to the end of the list. All of the headers get sent and my content type is ignored.
I also tried
request.getHeaders().remove("Content-Type");
but that threw an Unsupported Operation Exception.
Read more here: Source link
