Note that there are some explanatory texts on larger screens.

plurals
  1. POSending a PUT request with an arduino
    primarykey
    data
    text
    <p>I'm trying to send a JSON string via PUT from an arduino in order to control a philips Hue smart light. I've googled and found a lot about POST and GET, but not much on PUT. I'm attempting to PUT "{"on":false}" to my local Hue bridge (/api/[key]/lights/3/state), but don't now how to format it. Can anyone help? </p> <p>Here's the console info when I successfully send a request using the Hue's debugging tool: </p> <pre><code>Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Encoding gzip, deflate Accept-Language en-us,en;q=0.5 Connection keep-alive Content-Length 12 Content-Type text/plain; charset=UTF-8 Host 192.168.1.8 Referer http://192.168.1.8/debug/clip.html User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:12.0) Gecko/20100101 Firefox/12.0 </code></pre> <p>Here's what I been trying, unsuccessfully:</p> <pre><code> #include &lt;SPI.h&gt; #include &lt;Ethernet.h&gt; byte mac[] = { 0x90, 0xA2, 0xDA, 0x0D, 0x83, 0x9D }; byte ip[] = { 192, 168, 1, 199 }; byte gateway[] = { 192, 168, 1, 1 }; byte subnet[] = { 255, 255, 255, 0 }; void setup() { Ethernet.begin(mac, ip); Serial.begin(9600); delay(1000); } void loop() { EthernetClient client; IPAddress server(192,168,1,8); if (client.connect(server,80)) { client.println("PUT /api/[key]/lights/3/state HTTP/1.1"); client.println("Connection: keep-alive"); client.println("Content-Type: text/plain; charset=UTF-8"); client.println("Content-Length: 12"); client.println("\"on\":false"); } else { Serial.println("Connection Failed."); Serial.println(); } delay(5000); } </code></pre> <p>I've also tried it with:</p> <pre><code> "Content-Type: application/x-www-form-urlencoded" </code></pre> <p>rather than UTF-8. </p> <p>According to the API, turning a light on/off is supposed to just be a matter of sending a PUT request with {"on":true/false} to the Hue bridge.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload