1

Execute report and export pdf file

Topic: Execute report and export pdf file

Hello team,

Below are the details which I tray to execute the report but getting error  7


http://gps.tawasolmap.com/wialon/ajax.h … eport&
    params={
        "reportResourceId":58415,
        "reportTemplateId":1,
        "reportObjectId":2751,
        "reportObjectSecId":0,
        "interval":{
            "from":1600356249,
            "to":1601029614,
            "flags":0
        }
    }&sid=1f78547b0bca9c80445f43352bee2a62

{
"error": 7
}


As per API documentations

Error code    Description

7    Access denied

is there any setting that we have to update with penal, also


Next is I need to export this report to pdf file once I get a response from the above API

https://sdk.wialon.com/wiki/en/sidebar/ … ort_result

This I think, We have to use this

2

Execute report and export pdf file

Re: Execute report and export pdf file

Hello!

"reportResourceId" is resource ID (not user ID). After login you can look parameter "bact" is a resource ID of user under which login.

Diana Cheley
Wialon Hosting Expert
Gurtam
3

Execute report and export pdf file

Re: Execute report and export pdf file

Thanks a lot, it works like a charm

4

Execute report and export pdf file

Re: Execute report and export pdf file

Diana wrote:

Hello!

"reportResourceId" is resource ID (not user ID). After login you can look parameter "bact" is a resource ID of user under which login.


Hello Diana,
we have a problem.in ours case for eg, we can execute report and get response. But, in the response, we did'nt get the unit trips detail, we just get the sumary wich contain the start and the end of the trips. Note that the report template that we are using is an trips report template that whe had create on platform.

Tached screen explain more
1- report excec result form api
2- report exec result from platform
. Can you advice please ?

5

Execute report and export pdf file

Re: Execute report and export pdf file

Hi megb !

After you execute request, you get a report content (how much tables, which ones, which row levels have and etc)
Then you need to execute request to get tables data.

Using the request report/get_result_rows. It is suitable for most reports. However, it returns only rows of the top level. If you have a multilevel report, you need to make an additional request to get the rows of lower levels – report/get_result_subrows.
Using the request report/select_result_rows. It returns JSON that contains rows of all levels.

In my opinion is more convenient to use second request report/select_result_rows
For example,


https://hst-api.wialon.com/wialon/ajax.html?svc=report/select_result_rows&sid=02a11914b29a58aa81c602eed3df0396

params: {"tableIndex":11,"config":{"type":"range","data":{"from":0,"to":13,"level":1,"unitInfo":1}}}

in your case the corresponded "tableIndex"  and "rows" ("from"/"to") in “tables” array (for table  "name": "unit_trips")


Please look more deatiled example here also https://sdk.wialon.com/wiki/en/sidebar/ … es/reports


As some advice - you can always look at Developer Console which request is executed, when do some action on platform.

Diana Cheley
Wialon Hosting Expert
Gurtam
6

Execute report and export pdf file

Re: Execute report and export pdf file

hi dyana. thanks for your response. We tried what you advise but we always gets wrongs params.
According to our case, when we get the tables rows blelows, do you confirm this values of unit_trips :   "tableInd:" 1, "level":1 and the "from":0 ,"to":53 ?

Also does it possible to dm you for more explication? my email is megb@sliafrika.com

"tables": [
            {
                "name": "unit_stays",
                "label": "Parking",
                "grouping": {},
                "flags": 272,
                "rows": 55,
                "level": 1,
                "columns": 5,
                "header": [
                    "Beginning",
                    "End",
                    "Duration",
                    "Location",
                    "Temps total"
                ],
                "header_type": [
                    "time_begin",
                    "time_end",
                    "duration",
                    "location",
                    "duration_ival"
                ],
                "total": [
                    "2020-12-22 09:24:19",
                    "2021-01-20 17:59:54",
                    "28 days 0:11:47",
                    "",
                    "29 days 8:35:35"
                ],
                "totalRaw": [
                    {
                        "v": 1608629059,
                        "vt": 30
                    },
                    {
                        "v": 1611165594,
                        "vt": 30
                    },
                    {
                        "v": 2419907,
                        "vt": 40
                    },
                    {
                        "v": -348201.3876,
                        "vt": 0
                    },
                    {
                        "v": 2536535,
                        "vt": 40
                    }
                ]
            },
            {
                "name": "unit_trips",
                "label": "Voyage",
                "grouping": {},
                "flags": 400,
                "rows": 54,
                "level": 1,
                "columns": 6,
                "header": [
                    "Beginning",
                    "Initial location",
                    "End",
                    "Final location",
                    "Duration",
                    "Mileage"
                ],
                "header_type": [
                    "time_begin",
                    "location_begin",
                    "time_end",
                    "location_end",
                    "duration",
                    "mileage"
                ],
                "total": [
                    "2020-12-22 13:51:21",
                    "Cotonou, Benin",
                    "2021-01-20 07:48:23",
                    "N 1, Tillabéri, Niger, Ayerou Haoussa",
                    "1 days 8:23:48",
                    "1208 km"
                ],
                "totalRaw": [
                    {
                        "v": 1608645081,
                        "vt": 30
                    },
                    {
                        "v": 0,
                        "vt": 1
                    },
                    {
                        "v": 1611128903,
                        "vt": 30
                    },
                    {
                        "v": 0,
                        "vt": 1
                    },
                    {
                        "v": 116628,
                        "vt": 40
                    },
                    {
                        "v": 1208434.16318,
                        "vt": 10
                    }
                ]
            },
            {
                "name": "unit_stops",
                "label": "Arrêts",
                "grouping": {},
                "flags": 272,
                "rows": 2,
                "level": 1,
                "columns": 4,
                "header": [
                    "Début",
                    "Fin",
                    "Durée",
                    "Lieu"
                ],
                "header_type": [
                    "time_begin",
                    "time_end",
                    "duration",
                    "location"
                ],
                "total": [
                    "2021-01-19 13:31:40",
                    "2021-01-19 18:16:01",
                    "0:02:27",
                    ""
                ],
                "totalRaw": [
                    {
                        "v": 1611063100,
                        "vt": 30
                    },
                    {
                        "v": 1611080161,
                        "vt": 30
                    },
                    {
                        "v": 147,
                        "vt": 40
                    },
                    {
                        "v": -348201.3876,
                        "vt": 0
                    }
                ]
            }
        ],
        "attachments": []
    },

tried request

https://hst-api.wialon.com/wialon/ajax.html?svc=report/select_result_rows&params: {"tableIndex":1,"config":{"type":"range","data":{"from":0,"to":53,"level":1}}}&sid=312ce86cc0ad70bedd774e0573f883d6
7

Execute report and export pdf file

Re: Execute report and export pdf file

Hello!

In your example above the following table data :
first table Parkings ("unit_stays") ,  "tableIndex":0  as 1st element in array, named Parking, 5 columns ("header" array), 1 level grouping, rows = 55
second table Trips ("unit_trips"), "tableIndex":1, named "Voyage",  6 columns, rows = 54, level 1
3rd table Stops ( "unit_stops"), "tableIndex":2, named "Arrêts", 4 columns, level = 1, rows =2

So to get Trips data, you request is correct

Diana Cheley
Wialon Hosting Expert
Gurtam