Jump to content
  • This documentation is an older version of JasperReports Server REST API Reference. View the latest documentation.

    The rest_v2/reports service has a simple API for obtaining report output, such as PDF and XLS. The service also provides functionality to interact with running reports, report options, and input controls.

    This chapter includes the following sections:

    Running a Report
    Finding Running Reports
    Stopping a Running Report

    Running a Report

    The reports service allows clients to receive report output in a single request-response. The reports service is a synchronous request, meaning the caller will be blocked until the report is generated and returned in the response. For large datasets or long reports, the delay can be significant. If you want to use a non-blocking (asynchronous) request, see The reportExecutions Service.

    The output format is specified in the URL as a file extension to the report URI.

    Method

    URL

    GET

    http://<host>:<port>/jasperserver[-pro]/rest_v2/reports/
    path/to/report.<format>?<arguments>

    Argument

    Type/Value

    Description

    <format>

    output
    type

    One of the following formats: pdf, html, xls, xlsx, rtf, csv, xml, docx, odt, ods, jrprint.

    As of JasperReports Server 6.0, it is also possible to specify json if your reports are designed for data export. For more information, see the JasperReports Library samples documentation.

    page?

    Integer > 0

    An integer value used to export a specific page.

    ignore
    pagination?
    Boolean When set to true, the report will be generated as a single page. This can be useful for some formats such as csv. When omitted, this argument's default value is false and the report is paginated normally.

    <inputControl>

    String

    Any input control that is defined for the report. Input controls that are multi-select may appear more than once. See examples below.

    interactive?

    Boolean

    In a commercial editions of the server where HighCharts are used in the report, this property determines whether the JavaScript necessary for interaction is generated when exporting to HTML. By default it is true. If set to false, the chart is generated as a non-interactive image file.

    onePage
    PerSheet?

    Boolean

    Valid only for the XLS format. When true, each page of the report is on a separate spreadsheet. When false or omitted, the entire report is on a single spreadsheet. If your reports are very long, set this argument to true, otherwise the report will not fit on a single spreadsheet and cause an error.

    baseUrl

    String

    Specifies the base URL that the report will use to load static resources such as JavaScript files. You can also set the deploy.base.url property in the .../WEB-INF/js.config.properties file to set this value permanently. If both are set, the baseUrl parameter in this request takes precedence.

    Return Value on Success

    Typical Return Values on Failure

    200 OK – The content is the requested file.

    404 Not Found – When the specified report URI is not found in the repository.

    The follow examples show various combinations of formats, arguments, and input controls:

    http://<host>:<port>/jasperserver[-pro]/rest_v2/reports/reports/samples/AllAccounts.html (all pages)

    http://<host>:<port>/jasperserver[-pro]/rest_v2/reports/reports/samples/AllAccounts.html?page=43

    http://<host>:<port>/jasperserver[-pro]/rest_v2/reports/reports/samples/AllAccounts.pdf (all pages)

    http://<host>:<port>/jasperserver[-pro]/rest_v2/reports/reports/samples/AllAccounts.pdf?page=1

    http://<host>:<port>/jasperserver[-pro]/rest_v2/reports/reports/samples/EmployeeAccounts.html?

    EmployeeID=sarah_id

    http://<host>:<port>/jasperserver[-pro]/rest_v2/reports/reports/samples/Cascading_multi_select_report.html?

    Country_multi_select=USA&Cascading_state_multi_select=WA&Cascading_state_multi_select=CA

    note-icon-ns_28x28.png.0a4bde04c1d25a46db295091f14d7f1a.png

    JasperReports Server does not support exporting Highcharts charts with background images to PDF, ODT, DOCX, or RTF formats. When exporting or downloading reports with Highcharts that have background images to these formats, the background image is removed from the chart. The data in the chart is not affected.

    Finding Running Reports

    The reports service provides functionality to stop reports that are running. Reports can be running from user interaction, web service calls, or scheduling. The following method provides several ways to find reports that are currently running, in case the client wants to stop them.

    note-icon-ns_28x28.png.72655bfcd846773f224e4f95ec9c8c43.png

    This syntax of the reports service is deprecated. See The reportExecutions Service.

    Method

    URL

    GET

    http://<host>:<port>/jasperserver[-pro]/rest_v2/reports/path/to/report/

    http://<host>:<port>/jasperserver[-pro]/rest_v2/reports?<arguments>

    Argument

    Type/Value

    Description

    jobID?

    String

    Find the running report based on its jobID in the scheduler.

    jobLabel?

    String

    Find the running report based on its jobLabel in the scheduler.

    userName?

    String

    Name of user who has scheduled a report, in the format <username>%7C<organizationID>. In the commercial editions, %7C<organizationID> is required for all users except system admins (superuser).

    fireTime
    From?

    date/time

    Date and time in the following pattern: yyyy-MM-dd'T'HH:mmZ. Together, these arguments create a time range to find when the running report was started. Both of the range limits are inclusive. Either argument may be null to signify an open-ended range.

    fireTimeTo?

    date/time

    Return Value on Success

    Typical Return Values on Failure

    200 OK – The content is a list of execution IDs that can be used for cancellation.

    404 Not Found – When the specified report URI is not found in the repository.

    For security purposes, the search for running reports is has the following restrictions:

    The system administrator (superuser) can see and cancel any report running on the server.
    An organization admin (jasperadmin) can see every running report, but can cancel only the reports that were started by a user of the same organization or one of its child organizations.
    A regular user can see every running report, but can cancel only the reports that he initiated.

    Stopping a Running Report

    Use the following method to stop a running report, as found with the previous method.

    note-icon-ns_28x28.png.0c5a554f6bb6d45311de58d4ee8f9dab.png

    This syntax of the reports service is deprecated. See The reportExecutions Service.

    Method

    URL

    PUT

    http://<host>:<port>/jasperserver[-pro]/rest_v2/reports/<executionID>/status/

    Content-Type

    Content

    application/xml

    Either an empty instance of the ReportExecutionCancellation class or

    <status>cancelled</status>.

    Return Value on Success

    Typical Return Values on Failure

    200 OK – The content also contains:
    <status>cancelled</status>.

    204 No Content – When the specified execution ID is not found on the server, and the response body is empty.


    User Feedback

    Recommended Comments

    There are no comments to display.



    Guest
    This is now closed for further comments

×
×
  • Create New...