Data File Uploads
This page describes the basic process a device should follow to successfully upload data files to Spoke Zone.
The header of any data file API upload request should always include an x-access-token field with the device access token.
v2 API
The v2 API uses a two step process to upload a data file.
- POST
/api/v2/data-filesto setup the data file.- The body of the request should be in JSON format and include a
typevariable to determine the type of data file to be uploaded.- Example body:
{ "type": "log" }
- Example body:
- If the request was successful, the API will send a
200response with a JSON object containing theidof the newly created data file.- Use the
idfrom this response in the next request to specify which data file ID to upload content to.
- Use the
- The body of the request should be in JSON format and include a
- POST
/api/v2/data-files/:id/fileto upload the contents of the data file.- The body of the request should be in form-data format and requires a
filesfield with the file to be uploaded. - If the request was successful, the API will send a
200response with a JSON object containing the file upload path.
- The body of the request should be in form-data format and requires a
Notes
- If a device tries to upload an empty file, the Spoke Zone API will reject it with a
400response and aFile is emptymessage. - Devices should attempt to re-upload data files when the API responds with a
5xxerror code.
v1 API
The v1 API uses a single endpoint to upload data files to Spoke Zone.
- POST
/api/v1/deviceUser/read-only/saveLogFile- The body of the request should be in form-data format and include the following fields:
deviceIdcontaining the ID of the device that is trying to upload.uploadTypecontaining the data file type.filescontaining the data file to be uploaded.
- If the request was successful, the API will send a
200response containing the file upload path and the new data file’s ID.
- The body of the request should be in form-data format and include the following fields:
Notes
- If a device tries to upload an empty file, the Spoke Zone API ignores it and sends a
200response.- A
40xresponse can’t be sent in these situations because older devices in the field are programmed to attempt to re-upload files when they receive an error response, which would result in devices endlessly attempting to upload empty files.
- A
- There is a limit of 6 data file upload requests per device per minute for the v1 route.
- Trying to send more than 6 requests per minute will result in the API sending a
200response with the messageToo many files uploaded, this one is ignored.
- Trying to send more than 6 requests per minute will result in the API sending a
- Devices should attempt to re-upload data files when the API responds with a
5xxerror code.