upload_image
To upload a file for a unit, use the unit/upload_file method:
svc=unit/upload_file¶ms={
"eventHash": <text>,
"toHex": <uint>
}
Parameters
The request can contain the following parameters. The required parameters are marked with an asterisk (*).
Parameter | Description |
---|---|
toHex* | Use a bin to string parser: 0 — no, 1 — yes. |
eventHash | Event name which will be generated after uploading the image. |
Uploading the file
To upload a file, use a POST request with multiple contents (multipart/form-data), where one part contains the parameters and the other contains the file. For example:
Request URL: https://hst-api.wialon.com/wialon/ajax.html?svc=exchange/import_json&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"
{"eventHash":"jUploadForm1372772377019"}
------WebKitFormBoundaryhAXcAjtvh1D61XpC
Content-Disposition: form-data; name="eventHash"
{"toHex":1}
------WebKitFormBoundaryhAXcAjtvh1D61XpC
Content-Disposition: form-data; name="toHex"
jUploadForm1372772377019
------WebKitFormBoundaryhAXcAjtvh1D61XpC
Content-Disposition: form-data; name="import_file"; filename="file.zip"
Content-Type: application/zip
------WebKitFormBoundaryhAXcAjtvh1D61XpC--
Response
If the request is completed successfully, an empty object is returned:
{}
To make sure the file has been uploaded, use the requests/avl_evts method.
If the request fails, error code 4 is returned, indicating that the input parameters are invalid.