upload_tag_image
The upload_tag_image method is used to attach an image to a tag. The tags are used when assigning or separating passengers.
svc=resource/upload_tag_image¶ms={"itemId":<long>,
"tagId":<long>,
"eventHash":"<text>",
"oldItemId":<long>,
"oldTagId":<uint>}
&sid="<text>"
To delete the image, use the update_tag method.
Parameters
| Name | Description |
|---|---|
| itemId | Resource ID. |
| tagId | Tag ID. |
| eventHash | The name of the event which should be generated after attaching the image. Optional parameter. |
| oldItemId | The resource ID from which the tag (passenger) image should be copied. Optional parameter. |
| oldTagId | The tag ID the image of which should be copied. Optional parameter. |
To upload an image, use a POST request with multiple contents (multipart/form-data), where one part contains the parameters and the other contains the image.
Example:
Request URL: https://hst-api.wialon.com/wialon/ajax.html?svc=resource/upload_tag_image
Request Method: POST
Host: hst-api.wialon.com
Connection: keep-alive
Content-Length: 31755
Cache-Control: no-cache
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryB4wasXYYHLTNXHBl
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
------WebKitFormBoundaryB4wasXYYHLTNXHBl
Content-Disposition: form-data; name="params"
{"itemId":717314,"tagId":17,"eventHash":"jUploadForm1372768554999"}
------WebKitFormBoundaryB4wasXYYHLTNXHBl
Content-Disposition: form-data; name="eventHash"
jUploadForm1372768554999
------WebKitFormBoundaryB4wasXYYHLTNXHBl
Content-Disposition: form-data; name="tags_dlg_props_upload_image"; filename="image.jpg"
Content-Type: image/jpeg
------WebKitFormBoundaryB4wasXYYHLTNXHBl--
It is also possible to copy an image from another tag (passenger). To do this, execute a request with no image but with the oldItemId and oldTagId fields.
Returned result
If the request is successful, an empty JSON is returned.
{ }
If not, an error code is returned. Possible error codes:
| Code | Description |
|---|---|
| 7 | The resource doesn’t exist, the user doesn’t have the Create, edit, and delete passengers access right to it, or the resource or tag with the oldItemId or oldTagId isn’t found (when copying the image from another tag). |
| 6 | Undefined error. |
| 4 | Wrong input parameters. |
To make sure that the image has been uploaded, execute the avl_evts request:
{
"tm":<uint>, /* current server time (UTC) */
"events":[
{
"i":<long>, /* tag ID (-1 if unknown) */
"d":{ /* data */
"hash":"<text>" /* the uploading is complete */
}
}
]
}