在节点js中使用https建立到alexa(AVS)的下行通道流正在提供解析错误

时间:2016-11-08 13:02:58

标签: node.js alexa alexa-voice-service alexa-skill

我正在尝试使用https在nodejs中建立alexa语音downchannel流但是我得到解析错误。这是代码

var https = require('https'); 

var fs = require('fs'); 

//read the accesstoken from text file.
var accessToken = fs.readFileSync('accessToken.txt','utf8');

 var options = {
    host: 'avs-alexa-na.amazon.com',
    path: '/v20160207/directives',
    scheme : 'https',
    method: 'GET',
    headers: {'Authorization': 'Bearer ${accessToken}'}
  };


var req = https.request(options, function(res) {
  console.log('STATUS: ' + res.statusCode);
  console.log('HEADERS: ' + JSON.stringify(res.headers));
  res.setEncoding('utf8');
  res.on('data', function (chunk) {
    console.log('BODY: ' + chunk);
  });
});
req.on('error', function(e) {
  console.log('problem with request: ' + e.message);
});
req.end();

当我运行上面的代码时,我收到错误

problem with request: Parse Error

你能不能帮助我在哪里犯错误。

0 个答案:

没有答案