Skip to content

The options Service

This chapter describes the rest_v2/reports/options service. Report options are sets of input control values that are saved in the repository. A report option is always associated with a report.

A report option contains input control values that you can read and modify with the inputControls service. Therefore, you should use the methods of the options service to create and list report option resources in the repository, and use the methods of the inputControls service to view and modify the values contained in a report option. For more information, see The inputControls Service.

This chapter includes the following sections:

Listing Report Options

The following method retrieves a list of report options summaries. The summaries give the name of the report options, but not the input control values that are associated with it.

Method

URL

GET

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

Options

accept: application/json

Return Value on Success

Typical Return Values on Failure

200 OK - The content is a JSON object that lists the names of the report options for the given report.

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

The body of the response contains the labels of the report options, for example:

{
  "reportOptionsSummary": [{
    "uri": "/reports/samples/Options",
    "id": "Options",
    "label": "Options"
  },
  {
    "uri": "/reports/samples/Options_2",
    "id": "Options_2",
    "label": "Options 2"
  }]
}

Creating Report Options

The following method creates a report option for a given report. A report option is defined by a set of values for all the report’s input controls.

Method

URL

POST

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

Argument

Type/Value

Description

label

string

The name to give the new report option.

overwrite?

true / false

If set to true, any report option with the same label is replaced.

If set to false or omitted, any report option with the same label will not be replaced.

Content-Type

Content

application/json

A JSON object that lists the input control selections. See the example below.

Options

accept: application/json

Return Value on Success

Typical Return Values on Failure

200 OK - The content is a JSON object that describes the new selection of input control values.

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

In this example, we create options for the sample report named Cascading_multi_select_report:

http://<host>:<port>/jasperserver[-pro]/rest_v2/reports/reports/samples/Cascading_multi_select_report/options?label=MyReportOption

With the following request body:

{
   "Country_multi_select":["Mexico"],
   "Cascading_state_multi_select":["Guerrero", "Sinaloa"]
}

When successful, the server responds with a JSON object that describes the new report options, for example:

{
  "uri":"/reports/samples/MyReportOption",
  "id":"MyReportOption",
  "label":"MyReportOption"
}

Updating Report Options

Use the following method to modify the values in a given report option. You can also use the methods of the inputControls service to view and modify the values contained in a report option. For more information, see The inputControls Service.

Method

URL

PUT

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

Content-Type

Content

application/json

A JSON object that lists the input control selections. See the example below.

Return Value on Success

Typical Return Values on Failure

200 OK

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

For example, we change the report option we created in 1.1, “Creating Report Options,” on page 1 with the following header:

http://<host>:<port>/jasperserver[-pro]/rest_v2/reports/reports/samples/Cascading_multi_select_report/options/MyReportOption

And the following request body:

{
   "Country_multi_select":["USA"],
   "Cascading_state_multi_select":["CA", "WA"]
}

Deleting Report Options

Use the following method to delete a given report option.

Method

URL

DELETE

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

Return Value on Success

Typical Return Values on Failure

200 OK

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