繁体   English   中英

HTTP 发布请求适用于 Postman 但不适用于 VS 代码

[英]HTTP post request that works in Postman but does not work in VS code

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

授权应该是 header,而不是 URL 参数。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM