Ubidots Community

HTTP POST JSON payload not valid for an Array of Objects


I am trying to use a Flespi Stream to push HTTP POST JSON data to https://industrial.api.ubidots.com/api/v1.6/devices/<device_label>/ but the Flespi HTTP body looks like an Array of JSON objects -

[{“battery.current”: 0,“battery.level”: 89,“battery.voltage”: 4}]

and this results in the HTTP Response -

{“code”: 400001,“message”: “The payload sent is not a valid json document.”}

but if I remove the [] brackets, everything works as expected and I get -


So, is ubidots correct in stating this is not valid JSON ?

Thanks, Nick.

Hello, Nick

You’re right, an array of objects is a valid JSON but the device’s endpoint, which is synchronous, was not conceived to receive an array of objects. It only accepts one single object that may hold nested objects. An array is valid in general but not for that endpoint and that is why you get that message.

On the other hand, an array of JSON objects is valid and is the format accepted for asynchronous endpoints such as the ones for bulk updates, that allows you to update one or multiple devices with multiple dots as can be seen in our documentation in the links below.

So, what is the difference between synchronous and asynchronous endpoints?

A synchronous endpoint is meant to work in real-time, you will get the data stored and visible in the platform immediately whereas asynchronous endpoints return a task that is enqueued and processed in a FIFO(First in First out) fashion. Data sent over that endpoint is not stored immediately and may take from a few seconds up to a few minutes(depending on how large is the payload) to be available in your account. Does this make sense? I’ll be attentive to your comments.

Kind Regards,


Hey Santiago,

Really appreciate your prompt response here and follow your thoughts on the synchronous / asynchronous aspects. It makes perfect sense.

Let me go try the Bulk data to a device and come back to confirm if working …

Kind regards, Nick.

Hello Santiago,

Bulk data to a device, using https://industrial.api.ubidots.com/api/v1.6/devices/<device_label>/_/bulk/values works just fine.

Many thanks for your assistance.

Kind regards, Nick.

You’re welcome and thanks for letting us know that it works!