Node JS ERROR: "the request could not be satisfied"

Node JS ERROR: "the request could not be satisfied"

我正在使用 Node JS 并尝试从 AWS 调用 Lambda 函数。 我收到错误:无法满足请求 状态:403

var opts = {
  host: 'myhost.amazonaws.com',
  region: 'us-east-1',
  service: 'execute-api',
  path: '/mypath',
  method: 'POST',
  headers:{
    'Content-Type': 'application/json'
    }   
};

var req = http.request(opts, function(res){
  console.log('Status: ' + res.statusCode);
  console.log('Headers: ' + JSON.stringify(res.headers));
  res.setEncoding('utf8');
  res.on('data', function (body){
    console.log('Body: ' + body);
   });
});

req.on('error',function(e){
  console.log('problem with request: '+ e.message);
});

req.end();

不知道是不是我的语法有误。

谢谢

对 AWS 服务一无所知,但通常 403 错误代码意味着 "forbidden",因此它应该与安全问题有关,无法针对服务器进行身份验证或类似的事情

尝试从浏览器或使用 cUrl 或 wget 执行查询。如果它也失败了,那不是你的语法问题,这是一个安全问题

使用 https 而不是 http,我希望这会起作用。