exec_report

The exec_report method is used to execute a report.

Endpoint

Copied!
svc=report/exec_report&params={
  "reportResourceId": <long>,
  "reportTemplateId": <long>,
  "reportObjectId": <long>,
  "reportObjectSecId": <long>,
  "reportObjectIdList": [
    <uint>,
    ...
  ],
  "interval": {
    "from": <uint>,
    "to": <uint>,
    "flags": <uint>
  },
  "remoteExec": <uint>,
  "reportTemplate": <object>
}

Parameters

The request can contain the following parameters. The required parameters are marked with an asterisk (*).

Name Description
reportResourceId* Resource ID. The report is executed on behalf of the resource creator if the reportTemplateId is 0.
reportTemplateId* Template ID.
reportObjectId* Item ID.
reportObjectSecId* Subitem ID (driver, trailer, or their groups); 0 if the item has no subitems.
reportObjectIdList The array of extra item IDs (for the report on unit groups).
interval* The settings of report interval.
from* The beginning of the interval, Unix time.
to* The end of the interval, Unix time.
flags* Interval flags.
remoteExec Specify 1 for this parameter to execute the report on the Webreport server. The parameter is optional and is only used if the report/get_report_status request is executed later. If the JSON response includes "remoteExec":1, it means the server has accepted the report for processing, and the execution timeout is 5 minutes.
Specify 0 or omit this parameter to execute the report on the Web server. In this case, the execution timeout is 2 minutes.
reportTemplate The JSON of the report template, which you can get after the get_report_data request. The parameter is optional and only used if the reportTemplateId is 0. The tbl array of the template must contain at least one table.

Interval flags

Flag Description The value of the from parameter The value of the to parameter Comments
0x00 (0) Specified interval. Timestamp value in seconds. Timestamp value in seconds.
0x01 (1) Starts from the specified time until today. Timestamp value in seconds. 0 Any value introduced in the parameter is replaced with the current server time.
0x02 (2) For previous n days. 0 The number of days. Any value introduced in the from parameter is replaced with the last full period or the current server time if the 0x20 flag is present.
0x04 (4) For previous n weeks. 0 The number of weeks.
0x08 (8) For previous n months. 0 The number of months.
0x10 (16) For previous n years. 0 The number of years.
0x20 (32) Including current.
0x40 (64) For previous n hours. 0 The number of hours.
0x80 (128) For previous n minutes. 0 The number of minutes.

Returned result

Copied!
{
    "reportResult": {                       /* report execution result */
        "msgsRendered": <int>,              /* messages loaded: 0 for no, 1 for yes */
        "stats": [                          /* the array of statistics parameters */
            ["<text>", "<text>"]            /* [parameter name, value] */
        ],
        "tables": [                         /* the array of tables */
            {
                "name": "<text>",           /* table type */
                "label": "<text>",          /* name */
                "grouping": {
                    "type": "<text>"        /* grouping type */
                },
                "flags": <uint>,            /* table flags (see below) */
                "rows": <uint>,             /* the number of lines */
                "level": <uint>,            /* the maximum level in the table */
                "columns": <uint>,          /* columns count */
                "header": ["<text>"],       /* the array of table headers */
                "total": [                  /* total */
                    "<text>"                /* the array of cells */
                ],
                "header_type": ["<text>"],  /* the array of table header types */
                "totalRaw": [               /* the array of values of the line "Total" */
                    {
                        "v": <double>,      /* original cell value */
                        "vt": <double>      /* value type */
                    },
                    ...
                ]
            }
        ],
        "attachments": [                    /* the array of attachments (charts, photos) */
            {                               /* for charts */
                "name": "<text>",           /* name */
                "type": "<text>",           /* type: chart, photo */
                "datasets": ["<text>"],     /* the array with the names of the chart's curved lines */
                "axis_y": ["<text>"],       /* the array with the labels of 'Y' axes */
                "axis_x": "<text>",         /* the name of the 'X' axis */
                "flags": <uint>,            /* axis format, see the description below */
                "p": "<text>"               /* chart settings */
            },
            {                               /* for photo and video */
                "name": "<text>",           /* name and following parameters separated by ";" */
                "ftm": "<text>",            /* formatted date */
                "uid": "<text>",            /* unit ID */
                "tm": "<text>",             /* Unix time */
                "idx": "<text>",            /* the index of the same-type attachments registered simultaneously */
                "lat": "<text>",            /* latitude */
                "lon": "<text>",            /* longitude */
                "type": "<text>",           /* attachment type */
                "zone": <JSON>,             /* geofence information */
                "tags": <JSON>              /* information about tags */
            }
        ]
    },
    "reportLayer": {                        /* graphic layer */
        "name": "<text>",                   /* layer name */
        "bounds": [
            <double>,                       /* minimum latitude */
            <double>,                       /* minimum longitude */
            <double>,                       /* maximum latitude */
            <double>                        /* maximum longitude */
        ]
    },
    "layerCount": <uint>                    /* the number of layers to be merged in the report layer */
}

To get all available table types, use the report/get_report_tables method.

For the zone field details, see the resource/get_zone_data page.

For the tags field details, see the resource/update_tag page.

Table flags

Flag Description
0x1 (1) Grouping by days.
0x2 (2) Time limitation.
0x4 (4) Grouping by weeks.
0x8 (8) Grouping by months.
0x10 (16) Total.
0x20 (32) Charts: split sensors.
0x100 (256) Detalization: partial.
0x200 (512) Charts: count from zero.
0x400 (1024) Accumulate intervals.
0x800 (2048) Detalization: full.
0x1000 (4096) Row numbering.
0x2000 (8192) Execute table only by report item (not subitems).
0x4000 (16384) Group records into shifts.
0x8000 (32768) Cut intervals in the table.
0x200000 (2097152) Grouping by trips.
0x400000 (4194304) Grouping by violation type.
0x10000000 (268435456) Grouping by the day of the week.
0x20000000 (536870912) Grouping by day of the month.
0x40000000 (1073741824) Grouping by years.

Chart flags

Flag Additional flag Description
0x4 (4) Correct maximum for the Y axis.
0x10 (16) The format specified in the template settings.
0x1 (1) Additional for 0x10 (Set format to “H:M:S”).
0x2 (2) Additional for 0x10 (Set format to “Y-m-E”).
0x80 (128) Generic type.
0x100 (256) 24-hour format.
0x20 (32) 24-hour format (additional for 0x100).
0x2 (2) 12-hour format (additional for 0x20).
0x40 (64) Display days of the week (additional for 0x100).

Error codes

Code Description
4 Wrong input parameters. For example, the tbl array in the reportTemplate parameter is empty. A template must contain at least one table.
6 Undefined error.
7 One of the following errors:
  • the report service isn’t available on the server
  • the item from reportObjectId doesn’t exist or you have no Request reports and messages access right to it
  • the resource from reportResourceId doesn’t exist or you have no View report templates access right to it

If you find a mistake in the text, please select it and press Ctrl+Enter.