Import latitude and longitude using RemoteAPI

Topic: Import latitude and longitude using RemoteAPI


I need to Import  latitude and longitude using RemoteAPI. Please suggest


Import latitude and longitude using RemoteAPI

Re: Import latitude and longitude using RemoteAPI

If you need to set unit position, there is only two ways to achieve this: send message via hardware protocol of your unit or to use exchange/import_messages.

To see format of import_messages input data, you can export messages from some unit to WLN and open it in text editor.


Import latitude and longitude using RemoteAPI

Re: Import latitude and longitude using RemoteAPI

Thank you for Reply.

I have tested with a UNIT getting error messages.


Please check my code and let me know if any working example.


Import latitude and longitude using RemoteAPI

(edited by rual 28/08/2018 11:34:17)

Re: Import latitude and longitude using RemoteAPI

Working example for NodeJS 8:

const https = require('https');

const SID = process.env.SID,
      ITEM_ID = parseInt(process.env.ITEM_ID);

let multipartBoundary = '-----WialonFormBoundary', // must do not encounter in payload
    multipartBoundarySplitter = '--' + multipartBoundary;

let eventHash = 'importMessage' + Date.now();

let content = [{
    name: 'params',
    content: JSON.stringify({ itemId: ITEM_ID, eventHash: eventHash })
}, {
    name: 'file',
    filename: 'file.wln',
    contentType: 'text/plain',
    content: 'REG;2000000000;27.456872;53.905826;60;180;ALT:0.0;SATS:255;;;;'
}].map(function(obj) {
    let lines = [multipartBoundarySplitter];

    let contentDispositionParams = [];

    contentDispositionParams.push('name="' + obj.name + '"');
    if (obj.filename) contentDispositionParams.push('filename="' + obj.filename + '"');

    lines.push('Content-Disposition: form-data; ' + contentDispositionParams.join('; '));

    if (obj.contentType) lines.push('Content-Type: ' + obj.contentType);

    lines.push(''); // newline


    return lines.join('\r\n');


content = content.join('\r\n');

let contentBuffer = Buffer.from(content, 'utf-8');

let contentLength = contentBuffer.length;

let req = https.request({
    method: 'POST',
    host: 'hst-api.wialon.com',
    path: '/wialon/ajax.html?svc=exchange/import_messages&sid=' + SID,
    headers: {
        'Content-Length': '' + contentLength,
        'Content-Type': 'multipart/form-data; boundary=' + multipartBoundary
}, function(res) {
    res.on('data', function(data) {


There is lon, lat, speed (60 km/h), course (180°), ALT, SATS:


2000000000 is a time in seconds. You can specify time in past, or if it will be in future (as in an example), wialon will use current time.

So, you need to send POST request with headers:

Content-Length: (number of bytes of body)
Content-Type: multipart/form-data; boundary=-----WialonFormBoundary

(beware of starting --, in body you will need to prepend two dashes to specified boundary in header)

And following body:

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

Content-Disposition: form-data; name="file"; filename="file.wln"
Content-Type: text/plain


(newline delimiters are \r\n)

Also, you can use your language library to send multipart/form-data requests and maybe make it more clear.

But if you have unit, that must be moved only programmatically, it is better to implement Wialon IPS and send messages as hardware.