MISE À JOUR: J'ai eu une erreur sur mon point de terminaison de demande http. Je n'avais pas défini les options d'authentification appropriées, ce qui a corrigé beaucoup d'erreurs possibles.Node.js Lambda Fonction "réponse non valide" Amazon Alexa
Ma question est semblable à un ici:
Cependant, la solution à cette question ne résout pas mon problème. Donc, je fais un appel de requête http à un service xsjs dans le cloud Hana. J'obtiens le message d'erreur "réponse non valide". Je ne peux pas voir pourquoi. Voici ma fonction:
// Create a web request and handle the response.
function httpGet(query, callback) {
console.log("/n QUERY: "+ query);
var host = 'datacloudyd070518trial.hanatrial.ondemand.com';
var path = '/LocationInformation/getLocationInfo.xsjs?location=';
var hostname = 'https://' + host + path + query;
var auth = 'user1:D1anafer';
var req = http.request({'hostname': hostname,
'auth': auth
}, (res) => {
var body = '';
res.on('data', (d) => {
body += JSON.stringify(d);
});
res.on('end', function() {
callback(body);
});
});
req.end();
req.on('error', (e) => {
console.error(e);
});
}
Et la fonction qu'il appelle:
'getNewsIntent': function() {
//self = this;
httpGet(location, function (response) {
// Parse the response into a JSON object ready to be formatted.
//var output = JSON.parse(response);
//output = output['change'];
var output = response;
var cardTitle = location;
var cardContent = output;
alexa.emit(':tellWithCard', output, cardTitle, cardContent);
});
},
Merci Vous -Diana