Webhook error / Faulty template?

I am referencing this wonderful work from Chip on the Sleephelper project:

I have assembled my bulk payloads:

And I'm using this webhook template:

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

But Ubidots is responding with an error:
{"results":[{"array":[{"status_code":400,"errors":{"error":{"message":"The value NaN is not in a valid range.","code":400001}}}]}]}

Any idea what I'm doing wrong?

That could be what I was referring to by using actual numbers as values. The template should probably look more like this:

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

The webhook editor will flag this as an error, but it should work properly.

That didn't change the error, Rick.

I'm wondering if I'm constructing my payload correctly.

Here's my code:

String data = "{";
        data += "\"ts\": \"" + String(sensorData.ts) + "\",";  // ts as a string
        data += "\"u\": " + String(sensorData.t1, 2) + ",";       // u as a numeric value
        data += "\"d\": " + String(sensorData.t2, 2) + ",";       // d as a numeric value
        data += "\"b\": " + String(sensorData.b, 2);              // b as a numeric value
        data += "}";

You can see my comments. Maybe I'm totally wrong. Are these correct?

Thanks

It's quite possible that the format you are sending to Ubidots is not what it's expecting, but I'm not familiar with it. Your template is quite a bit different than Chip's in the original post, and I'm also not sure what format is allowed. But I'd guess that the array is not constructed properly, so when Ubidots is trying to read the number it's getting something that's not a number (NaN error).

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.