json 在Postman中工作但在VS代码中不工作的HTTP post请求

dm7nw8vv  于 2023-08-08  发布在  Postman
关注(0)|答案(2)|浏览(157)

我有一个播放语音消息的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>

字符串

noj0wjuj

noj0wjuj1#

授权应该是一个标头,而不是URL参数。

ig9co6j1

ig9co6j12#

检查 Postman 和vscode中的标头和检查Cprs Origin

相关问题