Table of Contents

Import of messages

To import messages from a file, use the command exchange/import_messages:

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

:!: Current request can't be executed simultaneously with any request from this chapter and following requests:

Parameters

Name Description
itemId item ID
eventHash event name, which will be generated after messages will be imported (optional parameter)

To load a file, use a POST request with multiple contents (multipart/form-data).

For example:

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

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

{"itemId":898446,"eventHash":"jUploadForm1372773585167"}
------WebKitFormBoundarylvunQiir9AesO8qB
Content-Disposition: form-data; name="eventHash"

jUploadForm1372773585167
------WebKitFormBoundarylvunQiir9AesO8qB
Content-Disposition: form-data; name="messages_filter_import_file"; filename="4100.zip"
Content-Type: application/zip


------WebKitFormBoundarylvunQiir9AesO8qB--

Response

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

To be sure that messages has been imported, you can execute the command Events:

{
	"tm": <uint>,	/* current server time (UTC) */
	"events": [{
		"i": -1,
		"d": {			/* data */
		"hash": <text>,		/* upload is complete */
		"msgCount": <text>	/* imported messages count */
        }]
}