1

excute report using API

Topic: excute report using API

Good
How I can get values of reportResourceId, reportTemplateId, reportObjectId and reportObjectSecId

https://hst-api.wialon.com/wialon/ajax. … eport&
    params={
        "reportResourceId":163266,
        "reportTemplateId":10,
        "reportObjectId":34868,
        "reportObjectSecId":0,
        "interval":{
            "from":1357938000,
            "to":1358715599,
            "flags":0
        }
    }&sid=<your_sid>

2

excute report using API

Re: excute report using API

Hello!

You can get the id's for certain elements via request Search items by property - search element avl_resource (resource)  by it's name
Please look the example here.
Also you can watch the video lesson regarding to this topic (where are more information and examples how to use this request)

Diana Cheley
Wialon Hosting Expert
Gurtam
3

excute report using API

Re: excute report using API

I called:
https://hst-api.wialon.com/wialon/ajax.html?svc=core/search_items&params={"spec":{"itemsType":"avl_resource",    "propName":"sys_name","propValueMask":"*","sortType":"sys_name","propType":"property","or_logic":0},"force":1,"flags":1,"from":0,"to":0}&sid=31c903f13382aa84cf0761f885432e7e

the response was:
{
    "searchSpec": {
        "itemsType": "avl_resource",
        "propName": "sys_name",
        "propValueMask": "*",
        "sortType": "sys_name",
        "propType": "property",
        "or_logic": "0"
    },
    "dataFlags": 1,
    "totalItemsCount": 1,
    "indexFrom": 0,
    "indexTo": 0,
    "items": [
        {
            "nm": "TechNet",
            "cls": 3,
            "id": 21575802,
            "mu": 0,
            "uacl": 60610577498111
        }
    ]
}

How I can get values of reportResourceId, reportTemplateId, reportObjectId and reportObjectSecId from the that response ?

4

excute report using API

Re: excute report using API

Hello!

To get information about report templates you need to specify correct value for dataFlags - please look here https://sdk.wialon.com/wiki/en/sidebar/ … t/resource
Also please watch the video lesson where it explained how to obtain data using different flags values.

Diana Cheley
Wialon Hosting Expert
Gurtam
5

excute report using API

Re: excute report using API

Hello Diana,
Can you give an example to get the following values?
reportResourceId, reportTemplateId, reportObjectId and reportObjectSecId

6

excute report using API

Re: excute report using API

Hello,

In order to get reportResourceId and reportTemplateId, you can use the request you've indicated in your previous topic. Set "flags" parameter value 8193
Thus response contains all resources available for the current user and report templates created there.

e.g. https://hst-api.wialon.com/wialon/ajax.html?svc=core/search_items&params={"spec":{"itemsType":"avl_resource",    "propName":"sys_name","propValueMask":"*","sortType":"sys_name","propType":"property","or_logic":0},"force":1,"flags":8193,"from":0,"to":0}&sid=

reportObjectId - the same request can be used, but change "itemsType" parameter value to "avl_unit" and "flags" value to 1.
(in case you generate report for a single unit, otherwise the type should be selected accordingly)

reportObjectSecId -- this parameter should be specified only if you want to generate report for sub-item, like driver, geofence etc.
And in this case, "reportObjectId" is resource ID and "reportObjectSecId" - ID of the driver/geofence created in this resource.
ID of the driver and geofence, can be retrieved similar as report template ID, but flag should be different.
Please, pay your attention to the flag values described in the documentation -- https://sdk.wialon.com/wiki/en/sidebar/ … mat/format
These values affect response content and can be merged to get more specific information in one request.

Anton Zinovyev
Technical Care Engineer (L2)
Wialon
7

excute report using API

Re: excute report using API

in this response:
{
    "searchSpec": {
        "itemsType": "avl_resource",
        "propName": "sys_name",
        "propValueMask": "*",
        "sortType": "sys_name",
        "propType": "property",
        "or_logic": "0"
    },
    "dataFlags": 8193,
    "totalItemsCount": 1,
    "indexFrom": 0,
    "indexTo": 0,
    "items": [
        {
            "nm": "TechNet",
            "cls": 3,
            "id": 21575802,
            "mu": 0,
            "rep": {
                "1": {
                    "id": 1,
                    "n": "Speeding",
                    "ct": "avl_unit",
                    "c": 27095
                }
            },
            "repmax": 0,
            "uacl": 60610577498111
        }
    ]
}
where is reportResourceId and reportTemplateId?

8

excute report using API

Re: excute report using API

Hello!

All parameters about report's templates  are described here in documentation - https://sdk.wialon.com/wiki/en/sidebar/ … t/resource

In your example,  "id": 21575802  - is resource ID,  "rep" is report's collection, where  "id": 1 is report template ID

Diana Cheley
Wialon Hosting Expert
Gurtam
9

excute report using API

Re: excute report using API

I tried :
https://hst-api.wialon.com/wialon/ajax.html?svc=report/exec_report&params={"reportResourceId":21575802,"reportTemplateId":1,"reportObjectId":21657018,"reportObjectSecId":0,"reportObjectIdList":[21657010,21657207]},"interval":{"from":1618059986000,"to":1619528786000,"flags":1},"remoteExec":1,"reportTemplate":0}&sid=...

but why the response is:
{
    "error": 4,
    "reason": "VALIDATE_PARAMS_ERROR: {reportResourceId: long, reportTemplateId: long, reportObjectId: long, reportObjectSecId: long, interval: {from: uint, to: uint, flags: uint}}"
}

10

excute report using API

Re: excute report using API

Hello!

1. If the report template is only for 1 unit, you need to pass only 1 unit ID in request
In you case previous responsed search items returned parameter  "ct": "avl_unit"  for report template, it means that report is only for 1 unit.

2. There is extra character } after "reportObjectIdList":[21657010,21657207]}

3. You can skip parameter "remoteExec":1 in your request,  this parameter is useful only when it needs to execute report at background.

4. The time values (from/two) should be in seconds, UTC+0. Not milliseconds like your values 1618059986000

5. The  request for example for unit with id = 21657018

https://hst-api.wialon.com/wialon/ajax. … session_id

params: {"reportResourceId":21575802,"reportTemplateId":1,"reportTemplate":null,"reportObjectId":21657018,"reportObjectSecId":0,"interval":{"flags":16777216,"from":1618059986,"to":1619528786}}
Diana Cheley
Wialon Hosting Expert
Gurtam
11

excute report using API

Re: excute report using API

Hello Diana,
sorry to bother you.
I tried this call:

https://hst-api.wialon.com/wialon/ajax.html?svc=report/exec_report&params={"reportResourceId":21573615,"reportTemplateId":3,"reportObjectId":21657207,"reportObjectSecId":0,"interval":{"flags":16777216,"from":1618059986,"to":1619528786}},"reportTemplate":0}&sid=...

The response was:
{
    "reportResult": {
        "msgsRendered": 0,
        "stats": [],
        "tables": [
            {
                "name": "unit_events",
                "label": "Events",
                "grouping": {},
                "flags": 16777216,
                "rows": 60,
                "level": 1,
                "columns": 2,
                "header": [
                    "Event time",
                    "Event text"
                ],
                "header_type": [
                    "time",
                    "evt_text"
                ]
            }
        ],
        "attachments": []
    }
}

bus this is only table columns
where is the data (60 rows) ?

12

excute report using API

Re: excute report using API

Hello,

In order to get detailed information from the report execution result, you can execute get_result_rows request -- https://sdk.wialon.com/wiki/en/sidebar/ … esult_rows
Please, note that this request should be executed within the same session as exec_report.

Please, find the detailed description with the steps and samples of getting table data -- https://sdk.wialon.com/wiki/en/sidebar/ … ables_data

Anton Zinovyev
Technical Care Engineer (L2)
Wialon
13

excute report using API

Re: excute report using API

ok
In that API:

https://hst-api.wialon.com/wialon/ajax.html?svc=report/exec_report&params={"reportResourceId":21573615,"reportTemplateId":3,"reportObjectId":21657207,"reportObjectSecId":0,"interval":{"flags":16777216,"from":1618059986,"to":1619528786}},"reportTemplate":0}&sid=...

How I can perform report for all objects (units) not only one?

14

excute report using API

Re: excute report using API

Hello, You can try to create a unit group with all required units. Then create a report templates for Unit group (current report template created for single unit).
Then you can provide units group ID in the "reportObjectId" parameter to execute the report for it.
In order to find units group ID is the same "search_items" request, but change the "itemsType" and "flags" parameters value to the corresponding once.
But, please, pay your attention to the restrictions that can affect report execution for the big amount of units -- https://sdk.wialon.com/wiki/en/sidebar/ … its/limits
If you reach one of them, corresponding error appears -- https://sdk.wialon.com/wiki/en/sidebar/ … ors/errors

Anton Zinovyev
Technical Care Engineer (L2)
Wialon