Ubidots Webhook to Control Things

Hello Particle forum,
First posting to the forum but have been lurking for some time.
Been using a Boron to send data to Ubidots without any problems. Added a relay to the Boron and there seems to be an issue. Tried using only the Ubidots sample code and have the same problem.
No events logged until the first time I send a control command to the Boron and then the events log fills with this:

HTTP/1.1 400 Bad Request
Server: nginx
Date: Tue, 13 Apr 2021 14:51:25 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.”}

The control works as desired but the events keep rolling in.
Which brings up a question, is every event considered a billable “data operation”?
The following code is copied from Ubidots “Create Ubidots Webhook to Particle to Control Things” doc.

// This #include statement was automatically added by the Particle IDE.
#include <Ubidots.h>

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);
    } 
}

Searched the forum for a while and didn’t see a similar issue. Any ideas where to go from here?
Thank You,
John

Hi John,

where to go from here? I would use pipedream to temporarily send the request from Ubidots into a “pipe” that can “simulate” the receiving Particle API, to where Ubidots will send the request:

then I would also play with curl (command line tool) to see what Particle expects.

Imagine you log in into pipedream (free) and create a pipe:

then you can send a GET request to it like this:

$ curl https://08b22b72c7e33747253dc2d5539a3fcf.m.pipedream.net

the answer I got was:

{ “success”: true }

what I see in pipedream:

I hope this helps. If not, keep asking!
Gustavo.

So what you are saying is it’s a Ubidots sample code problem, not a Particle issue. Maybe I need take this over to Ubidots. Thanks for the reply Gustavo!
John

Hey, no I am not saying that. That’s what I would do from there to troubleshoot and try to discover where the problem lies :slight_smile:
But taking it to the Ubidots community is also a good idea.
Gustavo.