Particle Webhook to /bulk/values not working

Hi, I need to determine if the following payload is a “bulk” upload or not. A given particle boron will assemble a payload of 1-9 events. Each event will have temp1, temp2, batt and a timestamp. The payload will be sent through the particle cloud to ubidots. I can assemble the json payload on the device or i can use a json template on the particle console. I have been assembling an array on the device, raw it looks like this:

{ “array”: [{“temperature1”: 26.535999,“temperature2”: 26.535999,“battery”: 1.128500,“timestamp”: 1722892093},{“temperature1”: 26.535999,“temperature2”: 26.535999,“battery”: 1.128500,“timestamp”: 1722892094},{“temperature1”: 26.535999,“temperature2”: 26.535999,“battery”: 1.128500,“timestamp”: 1722892095},{“temperature1”: 26.535999,“temperature2”: 26.343000,“battery”: 1.128500,“timestamp”: 1722892096},{“temperature1”: 26.535999,“temperature2”: 26.343000,“battery”: 1.128500,“timestamp”: 1722892097},{“temperature1”: 26.535999,“temperature2”: 26.343000,“battery”: 1.128250,“timestamp”: 1722892098}]}

then I have been using this template on the particle console:

{
  "array": [
    {{#data}}
    {
      "temperature1": "{{{t1}}}",
      "temperature2": "{{{t2}}}",
      "battery": "{{{b}}}",
      "timestamp": "{{{ts}}}000"
    },
    {{/data}}
    {}
  ]
}

I have been sending this to (shortened): /devices/{{{PARTICLE_DEVICE_ID}}}/_/bulk/values]

Everything looks good on the device, particle side, but no events or data are showing up on the ubidots side. From the particle console, I did send a Test to ubidots and my device ID did arrive correctly. So, I’m not sure what i’m doing wrong.

Perhaps what I’m doing is not a ‘bulk’ payload?

Looking for some guidance on what I’m doing wrong.

Thanks

Hello @Wineisgud4u

I can see that you’re sending an incorrect structure for the bulk payload. Please see the following image, you need to send a list of Objects, containing each group of variables, using a unique request for one device.

Please let me know if you need something else.

Alejandro

Do I need to use the /bulk/values api or the standard api?

Also, I’m quite inexperienced with this, so please forgive me. Is my json template on particle correct? Or, the issue is with the payload structure from my datalogger?

Still struggling with this. I tried sending this payload through the particle console with an empty json template. The payload is list of objects. I think. I sent it to the standard api.

[
  {
    "temperature1": 29.431000,
    "temperature2": 25.957001,
    "battery": 0.682250,
    "timestamp": 1723057971000
  },
  {
    "temperature1": 29.624001,
    "temperature2": 26.150000,
    "battery": 0.682000,
    "timestamp": 1723057972000
  },
  {
    "temperature1": 29.624001,
    "temperature2": 26.343000,
    "battery": 0.682250,
    "timestamp": 1723057973000
  },
  {
    "temperature1": 29.431000,
    "temperature2": 26.343000,
    "battery": 0.682250,
    "timestamp": 1723057974000
  },
  {
    "temperature1": 29.045000,
    "temperature2": 26.150000,
    "battery": 0.682250,
    "timestamp": 1723057975000
  },
  {
    "temperature1": 28.659000,
    "temperature2": 25.957001,
    "battery": 0.682000,
    "timestamp": 1723057976000
  }
]

This did not work. I simply do not understand what I’m doing wrong.

That last JSON you sent is correct, but you need to use the bulk endpoint:

https://industrial.api.ubidots.com/api/v1.6/devices/{{{PARTICLE_DEVICE_ID}}}/_/bulk/values

Ok, I used the bulk/values api as you show. I confirmed the json template was empty. Here is the confirmation from the Particle Console for the test. The console has a Test feature to see if the webhook is working. I sent the following simple data:

[{“temperature1”: 29.431000,“temperature2”: 25.957001,“battery”: 0.682250,“timestamp”: 1723057971000}]

I did get a successful response back from Ubi, however. So, it did receive the request.

When I checked Ubidots, for device “api”, there was no data. I don’t know if the console test support this type of data, however.

But, this did not work. Not sure why.

Which status code did you obtain in the request?

With that simple data, my recommendation is to use the normal API instead of the bulk endpoint. Here is the documentation:

Additionally, in this case, you need to make a simple change, because if you send the same JSON, you will see a variable in your device labeled “timestamp” and this is not what we want.

The body will be an object, instead a list of objects:

{
   "temperature1": {
      "value": 29.431,
      "timestamp": 1723057971000
   },
   "temperature2": {
      "value": 25.957001,
      "timestamp": 1723057971000
   },
   ...
}

here is the response code:
Screenshot 2024-08-08 141526

Been testing more concepts. Here is the current payload sent to the bulkvalues api:

and here is the json template I’m using to iterate through my payload:

[
    {
        "array": [
            {{#a}}
            {
                "timestamp": "{{{t}}}000",
                "temp_up": "{{{u}}}",
                "temp_down": "{{{d}}}",
                "battery": "{{{b}}}"
            },
            {{/a}}
            {}
        ]
    }
]

But I’m getting a webhook error:
{“results”:[{“array”:[{“status_code”:400,“errors”:{“error”:{“message”:“The value NaN is not in a valid range.”,“code”:400001}}}]}]}

Isn’t this the correct structure? And what could be causing this error?

Hello @Wineisgud4u

Did you change something in your devices? I can see that you’re receiving data correctly and have some other variables.

Is the webhook working fine now or you’re still seeing any error?

Yes, I figured out how to construct my json templates to accommodate my payload structure. However, the solution is crude. I’m still researching how to use a template that the particle console will iterate through. After I was having success with baseline data, I added more data and calculations to get exactly what I need. But I can move forward with field testing based on what is working today.

So, great progress made.

Thanks for checking in.

Great to know, let me know if I can help you from my end.

Hi, I’m trying to make a Bar Chart and I’m not able to find the option for aggregation method to show Raw data. See attached.

Thanks

Hello, Raw data does not apply as an aggregation method in that case. In the bar chart, each column represents each variable you add. So, we can only access to raw data using the Last Value’s method.

I noticed that you are now on the Professional License. For a more personalized support, you are able now to type here on the Contact Support channel.

image

Will do, thanks!

You’re welcome!