1

How do I know the values of my input parameters?

(19/06/2020 23:44:34 отредактировано fabrizio.pomata)

Тема: How do I know the values of my input parameters?

Hello. This might sound silly, but I have the following situation:

Our company acquired a fuel monitoring system powered by Wialon.
I am working on a python script to get the data from a report template and load it into the data warehouse (sql server).
I was able to connect with a token and get the eid.

Now I want to execute the svc=report/exec_report command. I tried following this guide: https://sdk.wialon.com/wiki/en/pro/remo … es/reports

The problem is I don't know what values to input on params. I mean, ¿Where can I find out the reportTemplateId corresponding to my desired template, for example? I don't know where can I find out any of my param values so I can input them into the command.

Thank you very much.

2

How do I know the values of my input parameters?

Re: How do I know the values of my input parameters?

fabrizio.pomata пишет:

Now I want to execute the svc=report/exec_report command. I tried following this guide: https://sdk.wialon.com/wiki/en/pro/remo … es/reports

The problem is I don't know what values to input on params. I mean, ¿Where can I find out the reportTemplateId corresponding to my desired template, for example? I don't know where can I find out any of my param values so I can input them into the command.

Thank you very much.

Hi Fabrizio,

First the report, which you would like to execute via API, should be created (in system) in some resource.
Then you can search resource by its name or by report's name to get  resource ID and its reports templates (names and id's)  , using request  core/search_items with the following params, for example searhching by report's name:

{
  "spec": {
    "itemsType": "avl_resource", //searching item
    "propName": "reporttemplates", //searching report as  subitem
    "propValueMask": "Diana", // report's name
    "sortType": "reporttemplates",  //searching report as  subitem
    "propType": "propitemname" //searching subitem (report)
  },
  "force": 1,
  "flags": 8193, //[url=https://sdk.wialon.com/wiki/en/sidebar/remoteapi/apiref/format/resource]flags[/url]: base flag =1 + 8192 report templates
  "from": 0,
  "to": 0
}

for example JSON response from server

{
  "searchSpec": {
    "itemsType": "avl_resource",
    "propName": "reporttemplates",
    "propValueMask": "Diana",
    "sortType": "reporttemplates",
    "propType": "propitemname",
    "or_logic": "0"
  },
  "dataFlags": 8193,
  "totalItemsCount": 1,
  "indexFrom": 0,
  "indexTo": 0,
  "items": [
    {
      "nm": "dianoch",
      "cls": 3,
      "id": 13,
      "mu": 0,
      "rep": {
        "1": {
          "id": 1,
          "n": "Diana",
          "ct": "avl_unit",
          "c": 53
        }
      },
      "repmax": -1,
      "uacl": 60507498283007
    }
  ]
}

where "items" shows recourse with thier reports : "nm":"dianoch", "id":13 - resource name/id (reportResourceId), "rep"(reports) - "id":1 =reportTemplateId  , report name =  "n": "Diana"

Diana Cheley
Wialon Hosting Expert
Gurtam
3

How do I know the values of my input parameters?

(22/06/2020 17:42:05 отредактировано fabrizio.pomata)

Re: How do I know the values of my input parameters?

This was very helpful, thank you very much.

Can I ask you another question? I did the items_search as you said and got the parameters. However, when I execute the report, I still get the 'wrong params' error code.
I believe my reportObjectId is not correct, and I am not sure what to put in there.

My response with item_search was:

{'searchSpec': {'itemsType': 'avl_resource', 'propName': 'reporttemplates', 'propValueMask': 'Cargas', 'sortType': 'reporttemplates', 'propType': 'propitemname', 'or_logic': '0'}, 'dataFlags': 8193, 'totalItemsCount': 1, 'indexFrom': 0, 'indexTo': 0, 'items': [{'nm': 'Reportes_Sentinel1', 'cls': 3, 'id': 187, 'mu': 0, 'rep': {'1': {'id': 1, 'n': 'Cargas', 'ct': 'avl_unit_group', 'c': 59921}, '2': {'id': 2, 'n': 'Consumo Flota', 'ct': 'avl_unit_group', 'c': 60324}, '3': {'id': 3, 'n': 'Control de Peajes', 'ct': 'avl_unit_group', 'c': 31006}, '4': {'id': 4, 'n': 'Descargas de combustible', 'ct': 'avl_unit_group', 'c': 19833}, '5': {'id': 5, 'n': 'Errores de Conducción', 'ct': 'avl_unit_group', 'c': 56306}, '6': {'id': 6, 'n': 'Excesos de Velocidad', 'ct': 'avl_unit', 'c': 2113}, '7': {'id': 7, 'n': 'Extended fuel report', 'ct': 'avl_unit', 'c': 4479}, '8': {'id': 8, 'n': 'Horas Motor', 'ct': 'avl_unit_group', 'c': 26206}, '9': {'id': 9, 'n': 'Infracciones y Multas', 'ct': 'avl_unit_group', 'c': 1276}, '10': {'id': 10, 'n': 'Contador de Viajes', 'ct': 'avl_unit', 'c': 31834}, '11': {'id': 11, 'n': 'Reporte de Paradas', 'ct': 'avl_unit_group', 'c': 7567}}, 'uacl': 17627904754211}]}

Then, in order to execute the report, this is what I do:

http://host/wialon/ajax.html?svc=report/exec_report&
        params={
            "reportResourceId":187,
            "reportTemplateId":1,
            "reportObjectId":59921,
            "reportObjectSecId":0,
            "interval":{
                "from":1590969600,
                "to":1592832842,
                "flags":1
            },
            "tzOffset":-14400,
            "lang":"en"
            }&ssid= my_eid

Thank you very much in advance.

4

How do I know the values of my input parameters?

Re: How do I know the values of my input parameters?

Hi Fabrizio,

there is not parameters "tzOffset"  and 'lang" in method svc=report/exec_report
If you need to get result with specific timezone (not only default UTC+0 time  ), after login you need to execute request render/set_locale

Please note also the parameter  "tzOffset" includes the value of DST settings
For example, for timezone -04:00 without DST  the value is "tzOffset":-134166592

Diana Cheley
Wialon Hosting Expert
Gurtam
5

How do I know the values of my input parameters?

Re: How do I know the values of my input parameters?

As i wants export report of the unit in pdf format with map location


Step 1

http://gps.tawasolmap.com/wialon/ajax.h … items&
    params={
        "spec":{
            "itemsType":"avl_resource",
            "propName":"reporttemplates",
            "propValueMask":"*",
            "sortType":"reporttemplates"
        },
            "force":1,
              "flags":8193,
              "from":0,
              "to":0
    }&sid=fe63cf3ea518ed7f25826d6e64a41e97

Got result as per that when i execute this command getting "error": 7

http://gps.tawasolmap.com/wialon/ajax.h … eport&
    params={
        "reportResourceId":55874,
        "reportTemplateId":10,
        "reportObjectId":63396,
        "reportObjectSecId":0,
        "interval":{
            "from":1357938000,
            "to":1358715599,
            "flags":0
        }
    }&sid=379644c21f3a467594d5118d8a9c5e0f

6

How do I know the values of my input parameters?

Re: How do I know the values of my input parameters?

Hello!

it seems like not correct "reportObjectId" or  "reportResourceId", please recheck

Diana Cheley
Wialon Hosting Expert
Gurtam
7

How do I know the values of my input parameters?

Re: How do I know the values of my input parameters?

Hi thanks for your reply

i got the below response an i have used

reportResourceId: 55874
reportObjectId :63396

{
  "searchSpec": {
    "itemsType": "avl_resource",
    "propName": "reporttemplates",
    "propValueMask": "*",
    "sortType": "reporttemplates",
    "propType": "",
    "or_logic": "0"
  },
  "dataFlags": 8193,
  "totalItemsCount": 1,
  "indexFrom": 0,
  "indexTo": 0,
  "items": [
    {
      "nm": "tawasoldemo",
      "cls": 3,
      "id": 55874,
      "mu": 0,
      "rep": {
        "1": {
          "id": 1,
          "n": "الأحداث",
          "ct": "avl_unit",
          "c": 14647
        },
        "2": {
          "id": 2,
          "n": "الأنتهاكات",
          "ct": "avl_unit",
          "c": 64143
        },
        "3": {
          "id": 3,
          "n": "التسلسل الزمني لحالة المركبة",
          "ct": "avl_unit",
          "c": 63396
        },
       
      },
      "repmax": 0,
      "uacl": 60610577498111
    }
  ]
}