The Servitly IoT Connectors use a predefined message payload format, which is a JSON document (UTF-8 encoded) with the following structure:
{
"ts": 1605179226000,
"data": {
"temperature": 23.5,
"humidity": 45,
"status": "OK",
"active": true
}
}
The JSON document must include the following predefined properties:
- ts: The timestamp in milliseconds relative to the data included in the data node; if missing, the server will consider the message reception time.
The timestamp is expressed as the difference, measured in milliseconds, between the time of the data and midnight, January 1, 1970 UTC. - data: The JSON node element containing all the metrics sent from the product.
Alternatively to data, you can also use a simple "d". This saves your network traffic (3 bytes for every message).
Into the data node, you can use any string key you prefer, but it is important that these keys match the name specified in the metric mapping panel.
In this way, the backend can extract the n-th field value and store it for the right metric.
Data field values can be strings, numbers, or booleans encoded by using the standard JSON data encoding.
For more details about how to encode values into the JSON payload, refer to the Encoding Values article.