import_messages

To import messages from a file, use the exchange/import_messages method.

Endpoint

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

Parameters

The required parameter is marked with an asterisk (*).

Parameter Description
itemId* Item ID.
eventHash Event name, which is generated after messages are imported.
dontMarkImported If this parameter is set to 1, the imported messages are marked as blackbox instead of imported, and the registration time may differ from the message time. If this parameter is missing or set to a value other than 1, the messages are marked as imported.

Loading a file

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

Copied!
Request URL: https://hst-api.wialon.com/wialon/ajax.html?svc=exchange/import_messages&sid=SESSION_IDENTIFIER
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

If the request is completed successfully, an empty response is returned.

Copied!
{ }	

To make sure that the messages have been imported, you can execute the avl_evts method.

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

If the request fails, an error code is returned.

Error codes

Error code Description
1 Invalid or obsolete request SID.
4 No file attached.
6 Internal error.
7 One of the following errors:
  • failed to fetch the user,
  • unit not found,
  • the user doesn’t have the Import messages access right to the unit.

If you find a mistake in the text, please select it and press Ctrl+Enter.