How can I send a json message with 'http.post' to the Philips Hue router?

50 views
Skip to first unread message

Hyunjoong Kang

unread,
Apr 17, 2014, 8:16:50 AM4/17/14
to karo...@googlegroups.com
Hi..
 
I'm trying to send a json message to the Philips Hue router to turn on a light with Karotz javascript api.
By studying the API of the Hue, I found the following method can turn the light on..
 
Payload: {"on":true}
 
 
After I found the method,
I made a main.js with following codes..
 
datapost = {"on":true};
header = { };
isForm = false;
 
http.post(url, datapost, header, isForm);
 
--->
 
Then, the following execption appears..
 
org.mozilla.javascript.WrappedException: Wrapped java.lang.ClassCastException: java.lang.Boolean cannot be cast to java.lang.String (init.js#45)
 
!!!!
 
Is there any way to solve this problem?
 
Thanks in advance..
 
 
Best!!!
 
 
hj Kang.
 

Olivier Oeuillot

unread,
Apr 18, 2014, 8:47:10 AM4/18/14
to karo...@googlegroups.com
Hello,
try :
datapost = {"on":"true"};

Regards,
Olivier

Hyunjoong Kang

unread,
Apr 18, 2014, 9:26:58 PM4/18/14
to karo...@googlegroups.com
Thanks..

I tried that but philips hue does not understand..
I think the reason is 'karotz datapost only sends string type..'

Olivier Oeuillot

unread,
Apr 21, 2014, 12:25:53 PM4/21/14
to karo...@googlegroups.com
Http Post supports only one format: String

Try different value for your parameter, or confirm your URL !

Regards,

Olivier
Reply all
Reply to author
Forward
0 new messages