Upload unit image

To upload an image for a unit, use the command unit/upload_image:

svc=unit/upload_image&params={"itemId":<long>,
			      "eventHash":<text>}

Parameters

Name Description
itemId unit ID
eventHash event name which will be generated after uploading the image (optional parameter)

To upload an image, use a POST request with multiple contents (multipart/form-data), where one part contains parameters and the other contains the image.

For example:

Request URL: https://hst-api.wialon.com/wialon/ajax.html?svc=unit/upload_image&sid=8157df114c0e601f0f31091c3c2ac53d
Request Method: POST
Host: hst-api.wialon.com
Connection: keep-alive
Content-Length: 31720
Cache-Control: no-cache
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryECovXn5tfw5muHk8
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

------WebKitFormBoundaryECovXn5tfw5muHk8
Content-Disposition: form-data; name="params"

{"itemId":911903,"eventHash":"jUploadForm1372769354768"}
------WebKitFormBoundaryECovXn5tfw5muHk8
Content-Disposition: form-data; name="eventHash"

jUploadForm1372769354768
------WebKitFormBoundaryECovXn5tfw5muHk8
Content-Disposition: form-data; name="icon_file"; filename="image.jpg"
Content-Type: image/jpeg


------WebKitFormBoundaryECovXn5tfw5muHk8--

Response

{}	/* empty object if execution successful, if not - error code */

To be sure that the image has been uploaded, execute the command Events:

{
	"tm":<uint>,				/* current server time (UTC) */
	"events":[
		{
			"i":<long>,				/* unit ID (-1 - unknown) */
			"d":{					/* data */
				"hash":<text>			/* upload is complete */
			}
		}
	]
}
Follow us on Facebook Gurtam Wialon Twitter Gurtam Wialon info@gurtam.com   |   Copyright © 2002-2024 Gurtam