We are about to switch to a new forum software. Until then we have removed the registration on this forum.
So I'm trying to do a simple POST to my Particle Photon, in HTML the post looks like this:
<!DOCTYPE>
<html>
<body>
<center>
<br>
<br>
<br>
<form action="https://api.particle.io/v1/devices/27003b000647343232363230/led?access_token=8a0770b34e49d68e8a5e829f2a8e5f0ccb20b2a5" method="POST">
Tell your device what to do!<br>
<br>
<input type="radio" name="args" value="on">Turn the LED on.
<br>
<input type="radio" name="args" value="off">Turn the LED off.
<br>
<br>
<input type="submit" value="Do it!">
</form>
</center>
</body>
</html>
I'm trying to use the [https://github.com/runemadsen/HTTP-Requests-for-Processing](HTTP Requests library) (version 0.1.2 because 0.1.3 is buggy). And my code looks like this:
import http.requests.*;
public void setup() {
background(255);
size(500, 500);
PostRequest post = new PostRequest("https://api.particle.io/v1/devices/27003b000647343232363230/led?access_token=8a0770b34e49d68e8a5e829f2a8e5f0ccb20b2a5");
post.addData("args", "on");
post.send();
System.out.println("Reponse Content: " + post.getContent());
println("Reponse Content-Length Header: " + post.getHeader("Content-Length"));
}
It works fine in the HTTP version, but I can't get Processing talking. Any advice??
Answers
Hey Scott, did you get this to work in the end?
I've been trying to do send POST requests to my Photon Particle, but haven't had much success.
I'm using the HTTP Requests for Processing library and here's what my POST requests are looking like:
It crossed my mind that the library may not support HTTPS.
I'll answer my own question. I was able to communicate with the device with the following code: