我有一个播放语音消息的http POST请求,它在 Postman 和subime文本上工作得很好,但在vscode中不工作。
<script type="text/javascript">
var request = require('request');
//process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
var headers = {
'Authorization': 'Basic YWRtaW46RHVubG9wMjAxNyo=',
'Content-Type': 'application/json'
}
var options = {
json: true,
url: 'https://srusa.local/10.11.208.10:8444/InformaCast/RESTServices/V1/Messages/2147483943' +
'?Authorization= Basic YWRtaW46RHVubG9wMjAxNyo=',
method: 'POST',
headers: headers,
body: {
"recipients": [{
"id": "2147483942",
"type": "RECIPIENT_GROUP"
}]
}
};
function callback(error, response, body) {
if (!error && response.statusCode == 200) {
console.log(body);
}
}
request(options, callback);
</script>
</head>
<body>
<center>
Javascript Post Request Test
</center>
</body>
</html>
字符串
2条答案
按热度按时间noj0wjuj1#
授权应该是一个标头,而不是URL参数。
ig9co6j12#
检查 Postman 和vscode中的标头和检查Cprs Origin