Upload JSON Data API
This API endpoint allows uploading data in JSON format with specific schema validation.
Endpoint
https://$ORG_BASE_URL/upload-json (POST)
Limitations
- Maximum payload size: 30MB
Expected JSON Format:
{
"start_time": Date,
"end_time": Date,
"request_id": Optional[String],
"data": {
"Sensor_Id | Sensor_Name": [
{
"timestamp": Date,
"value": Float | String | Boolean
},
...
],
...
}
}
Request Body
The request body should be valid JSON data conforming to the following schema:
JSON
{
"start_time": "2024-04-18T11:40:27.874Z",
"end_time": "2024-04-18T11:40:57.874Z",
"request_id": "slug",
"data": {
"Sensor_1": [
{
"timestamp": "2024-04-18T11:40:27.874Z",
"value": 22.234
},
{
"timestamp": "2024-04-18T11:40:42.874Z",
"value": 498575.234
},
{
"timestamp": "2024-04-18T11:40:57.874Z",
"value": "ON"
}
],
"Sensor_2": [
{
"timestamp": "2024-04-18T11:40:27.874Z",
"value": 44.543
},
{
"timestamp": "2024-04-18T11:40:42.874Z",
"value": 537955.235
},
{
"timestamp": "2024-04-18T11:40:57.874Z",
"value": "OFF"
}
]
}
}
Response
Success Response:
JSON
{
"message": "Data uploaded successfully."
}
Error Response:
In case of any errors during upload or data parsing, an error response with a detailed message will be returned. The error code will depend on the specific error:
- 401 (Unauthorized): Invalid Auth Token
- 413 (Payload Too Large): Request payload exceeds the 30MB limit
- 422 (Unprocessable Content): Invalid JSON data or schema validation error.
Example Usage (using curl):
Bash
curl --location https://$ORG_BASE_URL/upload-json \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer ••••••' \
--data '{
"start_time": "2024-04-18T11:40:27.874Z",
"end_time": "2024-04-18T11:40:57.874Z",
"request_id": "slug",
"data": {
"Sensor_1": [
{
"timestamp": "2024-04-18T11:40:27.874Z",
"value": 22.234
},
{
"timestamp": "2024-04-18T11:40:42.874Z",
"value": 498575.234
},
{
"timestamp": "2024-04-18T11:40:57.874Z",
"value": "ON"
}
],
}
}'
Replace $ORG_BASE_URL with the URL given by the Administrator.
Depending on the type of authentication used, additional headers may be necessary for the provided API.