In my case, I put Accept type into the request Header and it does work.
{"Accept": "*/*", "Content-Type":"application/json"}
Code snippet with pseudo data:
const getToken = () => {
try {
const response = https.post({
url: 'http://some-url/oauth/token?grant_type=client_credentials&client_id=1234&client_secret=5678',
headers: {"Accept": "*/*", "Content-Type":"application/json"},
body: "1"
});
if (response.body) {
//get response
}
} catch (ex) {
log.error(ex.name, ex.message)
}
}
Welcome to share your situation and solution.
For more info about Header https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept
我在http请求的Header中添加了Accept的类型,一切就正常了。
{"Accept": "*/*", "Content-Type":"application/json"}
含有瞎编信息的代码如下:
const getToken = () => {
try {
const response = https.post({
url: 'http://some-url/oauth/token?grant_type=client_credentials&client_id=1234&client_secret=5678',
headers: {"Accept": "*/*", "Content-Type":"application/json"},
body: "1"
});
if (response.body) {
//get response
}
} catch (ex) {
log.error(ex.name, ex.message)
}
}
如果你有其它解决方案也可以分享。
关于Header的帮助主题 https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept
Comments