Closed qkevinto closed 9 years ago
I have also been running into this issue. My code is as follows:
var hue = require('node-hue-api'),
HueApi = hue.HueApi,
lightState = hue.lightState,
elasticsearch = require('elasticsearch'),
client = new elasticsearch.Client({ host: '[host here]' }),
hostname = '[ip address here]',
username = 'zenahirsch',
api = new HueApi(hostname, username),
state = lightState.create();
var displayResult = function(result) {
console.log(JSON.stringify(result, null, 2));
};
api.setLightState(1, state.off(), function(err, lights) {
if (err) {
console.log(err);
}
displayResult(lights);
});
I get the following result:
{ [Api Error: body contains invalid json]
message: 'body contains invalid json',
type: 2,
address: '/lights/1/state' }
Can you check the version of request that is inside the request-util dependency of the hue-api?
I released an updated version of this support library to support the upcoming version 1.0.0 of the hue-api, and may have broken this. The new version of request changed the way the json property is interpreted and I suspect this may be your issue.
If confirmed, I can fix that quickly with a new patch release.
package.json within request shows "version": "2.51.0"
Ok, I should be able to fix that quickly...
I have just released version 0.0.3 of request-util that should resolve this issue.
Run npm update
on your project and it should pull this new version down which corrects the JSON issues.
Let me know if it works, and I can close out this issue.
Yes, it worked! Thank you so much!
I am very sorry for that, I should have properly followed my semver version numbers and incremented it as a patch...
Thanks for sharing such a great project! It seems to be very well written and well documented.
However I'm having a bit of trouble running some basic functions such as
registerUser()
andsetLightState()
. It constantly throws aApi Error: body contains invalid json
error. I have however been successful in running functions likeconnect()
anddeleteUser()
.I'm running on a Windows 8.1 environment, with node version 0.10.35 and bridge swversion 01018228.