6. Reporting REST API

The universal REST API provides the following functionality for the Reporting Add-on:

  • Getting a list of reports.

  • Getting the details on a specific report.

  • Running a report and getting the result.

  • Getting Swagger documentation.

REST API uses the OAuth2 protocol for authentication and supports anonymous access.

To make a report available through the REST API, select the Visible for REST API checkbox on the Roles and Screens tab:

visible for rest
Figure 72. Visible for REST API checkbox

Below we provide a formal description of some features specific to reporting. For more information on how to get an OAuth token and other REST API features, see Developer’s Manual.

Getting the list of existing reports

The list of existing reports can be retrieved with the following GET request:

/rest/reports/v1/report

For example:

GET http://localhost:8080/app/rest/reports/v1/report HTTP/1.1

Authorization: Bearer f5a2b4b1-a121-4563-9519-dd3c0b116689
Content-Type: application/json

The response body will contain the brief information on the reports marked as Visible for REST API:

{
    "id": "2dd27fbf-8830-416a-899f-339543f8f27a",
    "name": "Books by author"
},
{
    "id": "2f07c9fe-5d6d-48cf-876f-8c02ac1f6c3c",
    "name": "Book availability in department"
}
Getting the report info

The detailed information on a specific report is retrieved with the following GET request:

/rest/reports/v1/report/{id}

The last part of the query here is the report identifier, for example:

GET http://localhost:8080/app/rest/reports/v1/report/2dd27fbf-8830-416a-899f-339543f8f27a HTTP/1.1

The returned JSON object will contain the following information on the passed report:

{
    "id": "2dd27fbf-8830-416a-899f-339543f8f27a",
    "name": "Books by author",
    "templates": [
        {
            "code": "DEFAULT",
            "outputType": "XLS"
        }
    ],
    "inputParameters": [
        {
            "name": "Author",
            "alias": "author",
            "type": "ENTITY",
            "required": true,
            "hidden": false,
            "entityMetaClass": "library$Author"
        }
    ]
}
Running a report

To run a report, send the following POST request:

/rest/reports/v1/run/{id}

The last part of the query here is the report identifier, for example:

POST http://localhost:8080/app/rest/reports/v1/run/2dd27fbf-8830-416a-899f-339543f8f27a HTTP/1.1

The report parameters are passed in the request body:

{parameters: [{name: 'author',value: '4b3a21b0-d6b7-4161-b0b6-55f118fbaac5'}]}

To print a report with a non-default template, pass the template code in the request body:

{template: 'Template_1', parameters: [{name: 'author',value: '4b3a21b0-d6b7-4161-b0b6-55f118fbaac5'}]}
Getting the Swagger documentation

The complete Swagger documentation on the Reporting Add-on can be retrieved with the GET request on the address:

http://localhost:8080/app/rest/reports/v1/docs/swagger.json