Hopefully someone can enlighten me to whats happening here. I’m having a problem with errors after following this article:
Step 3. Send Multiple Variable to Ubidots, worked fine without errors.
Step 5. Create Ubidots Webhook to Particle to Control Things, not so lucky.
Using this with a Boron, even with all the errors the LED turns ON and OFF as it should.
Request
The HTTP request sent to the webhook url
X-Auth-Token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Content-Type: application/json
User-Agent: ParticleBot/1.1 (https://docs.particle.io/webhooks)
host: industrial.api.ubidots.com
content-length: 3
Connection: keep-alive
Response
The HTTP response received from the webhook url
HTTP/1.1 400 Bad Request
Server: nginx
Date: Mon, 19 Apr 2021 23:25:42 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
access-control-allow-origin: *
{"code":400001,"message":"The payload sent is not a valid json document."}
int led = D7;
float control = 0;
int i = 0;
void setup() {
Serial.begin(115200);
// Subscribe to the integration response event
Particle.subscribe("UbidotsWebhook", myHandler);
pinMode(led, OUTPUT);
}
float setControl(float value) {
if (value == 1) {
return 1;
}
return 0;
}
void myHandler(const char *event, const char *data) {
// Handle the integration response
i++;
Serial.println(i);
Serial.print(event);
Serial.print(", data: ");
if (data) {
Serial.println(data);
control = setControl(atof(data));
} else {
Serial.println("NULL");
}
}
void loop() {
if (control == 1) {
digitalWrite(led, HIGH);
} else {
digitalWrite(led, LOW);
}
}
Looks like the preformated text isn’t working right.
Any help would be much appreciated, It’s my first time using webhooks.
Thanks,
John