jishi / node-sonos-http-api

An HTTP API bridge for Sonos easing automation. Hostable on any node.js capable device, like a raspberry pi or similar.
http://jishi.github.io/node-sonos-http-api/
MIT License
1.83k stars 462 forks source link

Unable to invoke the function because invoke parameters were not valid JSON. #66

Closed themessings closed 8 years ago

themessings commented 8 years ago

Getting the following error when testing Lambda.

Unable to invoke the function because invoke parameters were not valid JSON. Thinking its in this json file but can't seem to fix.

{'use strict';

var http = require('http');

var options = require('./options');

var AlexaSkill = require('./AlexaSkill'); var EchoSonos = function () { AlexaSkill.call(this, options.appid); };

EchoSonos.prototype = Object.create(AlexaSkill.prototype); EchoSonos.prototype.constructor = EchoSonos;

EchoSonos.prototype.intentHandlers = { // register custom intent handlers PlayIntent: function (intent, session, response) { console.log("PlayIntent received"); options.path = '/preset/'+encodeURIComponent(intent.slots.Preset.value); httpreq(options, response, "Playing " + intent.slots.Preset.value); }, PauseIntent: function (intent, session, response) { console.log("PauseIntent received"); options.path = '/pauseall'; httpreq(options, response, "Pausing"); }, VolumeDownIntent: function (intent, session, response) { console.log("VolumeDownIntent received"); options.path = '/groupVolume/-10'; httpreq(options, response, "OK"); }, VolumeUpIntent: function (intent, session, response) { console.log("VolumeUpIntent received"); options.path = '/groupVolume/+10'; httpreq(options, response, "OK"); } };

// Create the handler that responds to the Alexa Request. exports.handler = function (event, context) { // Create an instance of the EchoSonos skill. var echoSonos = new EchoSonos(); echoSonos.execute(event, context); };

function httpreq(options, alexaResponse, responseText) { console.log("Trying http request with responseText " + responseText); http.request(options, function(httpResponse) { console.log(httpResponse.body); if (responseText) alexaResponse.tell(responseText); }).end(); }

themessings commented 8 years ago

looking in the Lambda log and this is the error it is communicating.

START RequestId: 6ef11aea-4344-11e5-9404-07ec8b018eee Syntax error in module 'index': SyntaxError at Module._compile (module.js:439:25) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Module.require (module.js:364:17) at require (module.js:380:17) END RequestId: 6ef11aea-4344-11e5-9404-07ec8b018eee REPORT RequestId: 6ef11aea-4344-11e5-9404-07ec8b018eee Duration: 3.66 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 28 MB

jishi commented 8 years ago

Well, doesn't look like this has anything to do with the http api. Are you trying to pass actual code as json data somehow? That won't work. Maybe open an issue with the author of the echo api, is that Matt Welch?