content-type header being overwritten during POST request

坚强是说给别人听的谎言 提交于 2020-03-25 19:41:47

问题


I have a web service that is making a HTTP POST request to "abc" API. For the POST request I need to have 3 things in the header , the customer id, secret key and content-type. For this POST request I will also have a raw json object in the request body. Upon successful POST, the abc API will return a response. The issue I'm having is the web service is modifying the "content-type" of the header to "text/xml" automatically even if I have it as "application/json".

I have to create a temporary workaround before the the bug in the web service is fixed. I was thinking of creating a proxy server on google app engine that I would make the request to instead. This proxy server would need to have code to correct the header type to "application/json", send the request with the original request header + request body and get the response from "abc" API.

How can I prevent this from happening? I have run POST tests on the API from Postman and I get the correct response from it. It is only when I do the POST request from my web service that the content-type is being overriden at the time of the request. I am not familiar with header content-type.

来源:https://stackoverflow.com/questions/60538094/content-type-header-being-overwritten-during-post-request

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!