multi_import

The exchange/multi_import method allows you to create units from a ZIP archive and import their messages. To create such an archive, use the exchange/multi_export method.

To use the method, the Import/Export service must be enabled for the account. Each WLP file in the archive counts as one use of the service.

In Wialon Local, this method is available starting from version 2304.

Endpoint

Copied!
svc=exchange/multi_import&params={
  "userId": <uint>
}

Parameters

Parameter Description
userId ID of the user who becomes the creator of the units. If the parameter isn’t specified, the current user becomes the creator. The creator can’t be the top user of the service.

Loading a file

To load the archive, use a POST request with multiple contents (multipart/form-data). If several files are attached, only the first one is processed. For example:

Copied!
Request URL: https://hst-api.wialon.com/wialon/ajax.html?svc=exchange/multi_import&sid=SESSION_IDENTIFIER
Request Method: POST
Content-Type: multipart/form-data; boundary=----WebKitFormBoundarylvunQiir9AesO8qB

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

{"userId":123456}
------WebKitFormBoundarylvunQiir9AesO8qB
Content-Disposition: form-data; name="file"; filename="multi_export.zip"
Content-Type: application/zip


------WebKitFormBoundarylvunQiir9AesO8qB--

The archive must contain the following files:

File Contents
<name>.wlp Unit properties. Required.
<name>.wlb Unit messages. Optional. The file must have the same name as the WLP file of the unit.

Importing units

For each WLP file in the archive, a new unit is created. Existing units aren’t updated. The unit properties from the file are applied to the new unit.

The device type is defined by its ID or name from the file. If the device type isn’t found, the device type with ID 899 (Wialon Retranslator) is set. If the server has no device type with this ID, the unit isn’t created.

The messages from the WLB file are imported only if the creator has the Import messages access right to the new unit.

If a unit can’t be created, it’s skipped, and no error is returned.

Response

If the request is completed successfully, the following response is returned:

Copied!
{
  "error": 0
}

If the request fails, an error code is returned.

Error codes

Error code Description
4 One of the following errors:
  • no file attached;
  • the archive doesn’t contain WLP files;
  • the user specified in userId doesn’t exist.
5 The creator of the units is the top user of the service.
6 Internal error, for example, the attached file isn’t a ZIP archive.
14 The account is blocked, or the Import/Export service isn’t available for the account.
1003 The limit on simultaneous resource-intensive requests is reached (the LIMIT api_concurrent reason).

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