thingsboard send multiple data to device with http api with curl in cmd

1k Views Asked by At

i am trying to send two number to thingsboard iot platform. send one data is like this : curl -v POST --data "{"photoresistor":10}" https://thingsboard.cloud/api/v1/nIjlT58Xo81AdU2Pwymm/telemetry --header "Content-Type:application/json"

but i do not know how to send two data to thingsboard . in my search i saw this

curl -v -X POST --data "{"temperature":42,"humidity":73}" https://demo.thingsboard.io/api/v1/ABC123/telemetry --header "Content-Type:application/json"

form https://thingsboard.io/docs/reference/http-api/

but any device should have one $ACCESS_TOKEN . and i can not use above command with two data "{"temperature":42,"humidity":73}" . because every device need one ACCESS_TOKEN.

please help me to solve this problem. thanks.

2

There are 2 best solutions below

0
JacksonB On

If you're using Thingsboard CE then you will need to get creative if you don't want to use access tokens. Possibly look at AWS lambda functions to act as a middle-man to forward messages.

If you're using Thingsboard PE then instead of posting to the device directly using it's ACCESS_TOKEN, you can use Integrations & Data Converters.

2
mdeuchert On

There is also a way to achieve this with ThingsBoard CE. You could use the MQTT Gateway API:

"Gateway API provides the ability to exchange data between multiple devices and the platform using single MQTT connection."

https://thingsboard.io/docs/reference/gateway-mqtt-api/#:~:text=Gateway%20API%20provides%20the%20ability%20to%20exchange%20data,below%20is%20used%20by%20ThingsBoard%20open-source%20IoT%20Gateway.

Still ACCESS_TOKEN is needed, but only one for the Gateway. You can publish messages of multiple devices in a single connection. Each device is identified by it's name. Also not existing devices are created automatically.