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.

This chapter includes the following sections:

Listing Report Options
Creating Report Options
Updating Report Options
Deleting Report Options

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 new report option for a given report. A report option is defined by a set of values for all of 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 true, any report option that has the same label is replaced. If 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 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 new 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.

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 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 Creating Report Options 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.

Version: 
Feedback