convert_file
To convert XLSX and CSV files into JSON, use the exchange/convert_file command:
svc=exchange/convert_file¶ms={"format":"csv", "separator":","}
The maximum file size is 64 MB.
Parameters
The required parameters are marked with an asterisk (*).
Parameter | Description |
---|---|
format* | File format. The supported formats are XLSX and CSV. |
separator* | Separator. Only for CSV files. |
eventHash | Name of the event which will be generated after reading the data. |
To convert a file, use a POST request with multiple parameters (multipart/form-data). In form-data, make a separate parameter of the file type and specify the file name. In Postman, for example, you can do this in query params.
Request example:
Request URL: https://hst-api.wialon.com/wialon/ajax.html?svc=exchange/convert_file&sid=8157df114c0e601f0f31091c3c2ac53d
Request Method: POST
Connection: keep-alive
Content-Length: 1901
Cache-Control: no-cache
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryhAXcAjtvh1D61XpC
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.3
Accept-Encoding: gzip,deflate,sdch
Accept-Language: ru,en-US;q=0.8,en;q=0.6
------WebKitFormBoundaryhAXcAjtvh1D61XpC
Content-Disposition: form-data; name="params"
jUploadForm1372772377019
------WebKitFormBoundaryhAXcAjtvh1D61XpC
Content-Disposition: form-data; name="import_file"; filename="file.zip"
Content-Type: application/zip
------WebKitFormBoundaryhAXcAjtvh1D61XpC--
Response
In case the file is converted successfully, a JSON text is returned. If the request didn’t contain the eventHash parameter, the response is returned immediately. If it did, you should run the avl_evts command to see the result.
Response example:
{
"filename": "test.xlsx",
"sheets": [
{
"rows": [
[
"№",
"Time",
"User",
"Object type",
"Action",
"Host",
"Notes"
],
[
"1",
"2023-09-13 10:45:15",
"maqsat",
"Resource",
"Resource 'Radares Maqsat' created.",
"167.61.60.214",
" "
],
[
"2",
"2023-09-13 10:45:16",
"maqsat",
"Resource",
"Account 'Radares Maqsat' created.",
"167.61.60.214",
" "
]
]
}
]
}
If conversion failed, an error code is returned.
Error codes
Code | Description |
---|---|
4 | Excessive file size, invalid input parameters, or unknown file format. |
5 | Failed to open or convert the file. |
6 | Unknown error. |
7 | No access. |