1

Wialon API in Python

Тема: Wialon API in Python

Hello guys

Im facing some troubles trying to automate a data extractin using Wialon API.

Every time I test it on Postman it works but when Im try it python I always receive the error 1

Can some one help me ?

The request Im trying is this one

svc=report/get_result_rows&params={\"tableIndex\":0,\"indexFrom\":0,\"indexTo\":10}\"&sid=MYSID

Kind Regards

2

Wialon API in Python

Re: Wialon API in Python

joao.lauro.de.marco hello, presumably, the error related to the encoding in this part }\"&sid
Please, send full request text used in your app.

Anton Zinovyev
Technical Care Engineer (L2)
Wialon
3

Wialon API in Python

Re: Wialon API in Python

Hello Gurtam,

this in a part of my code, Im using the requests library to make the reques

headers = {"sid":MYSID}

new_url_info = 'https://hst-api.wialon.com/wialon/ajax.html?svc=report/get_result_rows&params={"tableIndex":0,"indexFrom":0,"indexTo":4}'
resposta2 = requests.get(new_url_info,  headers=headers)

4

Wialon API in Python

Re: Wialon API in Python

joao.lauro.de.marco hello, the sid is a part of the parameters. If you use request library, you can pass the sid directly in params. Also, the request should be executed as post, not get.

For example:

import requests, json

base_url = 'https://hst-api.wialon.com/wialon/ajax.html'

response = requests.post(base_url, params={
    'svc': 'report/get_result_rows',
    'sid': 'SID',
    'params': json.dumps({
        "tableIndex":0,
        "indexFrom":0,
        "indexTo":4,
    })
})

response_data = response.json()
Anton Zinovyev
Technical Care Engineer (L2)
Wialon