# Publish data as an object without timestamp (server-side timestamp will be used). Replace $ACCESS_TOKEN with corresponding value.
curl -v-X POST --data"{"temperature":42,"humidity":73}" https://thingsboard.cloud/api/v1/$ACCESS_TOKEN/telemetry --header"Content-Type:application/json"# For example, $ACCESS_TOKEN is ABC123:
curl -v-X POST --data"{"temperature":42,"humidity":73}" https://thingsboard.cloud/api/v1/ABC123/telemetry --header"Content-Type:application/json"# Publish data as an object without timestamp (server-side timestamp will be used) using data from file. Replace $ACCESS_TOKEN with corresponding value.
curl -v-X POST -d @telemetry-data-as-object.json https://thingsboard.cloud/api/v1/$ACCESS_TOKEN/telemetry --header"Content-Type:application/json"# For example, $ACCESS_TOKEN is ABC123:
curl -v-X POST -d @telemetry-data-as-object.json https://thingsboard.cloud/api/v1/ABC123/telemetry --header"Content-Type:application/json"# Publish data as an array of objects without timestamp (server-side timestamp will be used) using data from file. Replace $ACCESS_TOKEN with corresponding value.
curl -v-X POST -d @telemetry-data-as-array.json https://thingsboard.cloud/api/v1/$ACCESS_TOKEN/telemetry --header"Content-Type:application/json"# For example, $ACCESS_TOKEN is ABC123:
curl -v-X POST -d @telemetry-data-as-array.json https://thingsboard.cloud/api/v1/ABC123/telemetry --header"Content-Type:application/json"# Publish data as an object with timestamp (telemetry timestamp will be used) using data from file. Replace $ACCESS_TOKEN with corresponding value.
curl -v-X POST -d @telemetry-data-with-ts.json https://thingsboard.cloud/api/v1/$ACCESS_TOKEN/telemetry --header"Content-Type:application/json"# For example, $ACCESS_TOKEN is ABC123:
curl -v-X POST -d @telemetry-data-with-ts.json https://thingsboard.cloud/api/v1/ABC123/telemetry --header"Content-Type:application/json"
# Publish client-side attributes update. Replace $ACCESS_TOKEN with corresponding value.
curl -v-X POST --data"{"attribute1": "value1", "attribute2":true, "attribute3": 43.0}" https://thingsboard.cloud/api/v1/$ACCESS_TOKEN/attributes --header"Content-Type:application/json"# For example, $ACCESS_TOKEN is ABC123:
curl -v-X POST --data"{"attribute1": "value1", "attribute2":true, "attribute3": 43.0}" https://thingsboard.cloud/api/v1/ABC123/attributes --header"Content-Type:application/json"# Publish client-side attributes update from file. Replace $ACCESS_TOKEN with corresponding value.
curl -v-X POST -d @new-attributes-values.json https://thingsboard.cloud/api/v1/$ACCESS_TOKEN/attributes --header"Content-Type:application/json"# For example, $ACCESS_TOKEN is ABC123:
curl -v-X POST -d @new-attributes-values.json https://thingsboard.cloud/api/v1/ABC123/attributes --header"Content-Type:application/json"
# Send HTTP attributes request. Replace $ACCESS_TOKEN with corresponding value.
curl -v-X GET "https://thingsboard.cloud/api/v1/$ACCESS_TOKEN/attributes?clientKeys=attribute1,attribute2&sharedKeys=shared1,shared2"# For example, $ACCESS_TOKEN is ABC123:
curl -v-X GET "https://thingsboard.cloud/api/v1/ABC123/attributes?clientKeys=attribute1,attribute2&sharedKeys=shared1,shared2"
# Send subscribe attributes request with 20 seconds timeout. Replace $ACCESS_TOKEN with corresponding value.
curl -v-X GET https://thingsboard.cloud/api/v1/$ACCESS_TOKEN/attributes/updates?timeout=20000
# For example, $ACCESS_TOKEN is ABC123:
curl -v-X GET https://thingsboard.cloud/api/v1/ABC123/attributes/updates?timeout=20000
We added support of JSON data structures to telemetry and attributes API to simplify work with device configuration.
JSON support allows you to both upload from the device, and push to device nested objects.
You can store one configuration JSON as a shared attribute and push it to the device. You can also process the JSON data in the rule engine and raise alarms, etc.
Therefore, this improvement minimizes the number of Database operations when ThingsBoard stores the data.
For example, “temperature” and “humidity” would be stored as separate rows in SQL or NoSQL databases in order to efficiently aggregate this data for visualization.
Since there is no need to aggregate JSON data, we can store all the content as one row instead of separate rows for each configuration item.
In some of our environments, it is possible to decrease the number of database operations more than 10 times by aggregating multiple parameters within one JSON.
Learn more about JSON value support with the video.
Use RPC debug terminal dashboard
Subscribe to RPC commands from the server. To do this, in the first terminal window send GET request with observe flag
Send an RPC request "connect" to the device
In the second terminal window simulate send a response from the device to the server
You should receive a response from the device: {"result":"ok"}
# Send rpc request with 20 seconds timeout. Replace $ACCESS_TOKEN with corresponding value.
curl -v-X GET https://thingsboard.cloud/api/v1/$ACCESS_TOKEN/rpc?timeout=20000
# For example, $ACCESS_TOKEN is ABC123:
curl -v-X GET https://thingsboard.cloud/api/v1/ABC123/rpc?timeout=20000
1
2
3
4
# Publish response to RPC request. Replace $ACCESS_TOKEN with corresponding value.
curl -v-X POST -d @rpc-response.json https://thingsboard.cloud/api/v1/$ACCESS_TOKEN/rpc/1 --header"Content-Type:application/json"# For example, $ACCESS_TOKEN is ABC123:
curl -v-X POST -d @rpc-response.json https://thingsboard.cloud/api/v1/ABC123/rpc/1 --header"Content-Type:application/json"
Add two nodes to the Rule Chain: "script" and "rpc call reply"
In the script node enter the function: return {msg: {time:String(new Date())}, metadata: metadata, msgType: msgType};
Send request to the server
You should receive a response from the server
# Send HTTP attributes request. Replace $ACCESS_TOKEN with corresponding value.
curl -X POST -d @rpc-client-request.json https://thingsboard.cloud/api/v1/$ACCESS_TOKEN/rpc --header"Content-Type:application/json"# For example, $ACCESS_TOKEN is ABC123:
curl -X POST -d @rpc-client-request.json https://thingsboard.cloud/api/v1/ABC123/rpc --header"Content-Type:application/json"