The resource Service

The resource service supports several HTTP methods to view, download, create, and modify resources in the repository.

GET is used to show the information about a specific resource. Getting a resource can serve several purposes:

In the case of JasperReports, also known as report units, this service returns the structure of the JasperReport, including resourceDescriptors for any linked resources.
For resources that contain files, specifying the fileData=true argument downloads the file content.
Specifying a query-based input control with arguments for running the query returns the dynamic values for the control.

A new service is also available to interact with report options. See section The v2/options Service.

Method

URL

GET

http://<host>:<port>/jasperserver[-pro]/rest/resource/path/to/resource/?<arguments>

Argument

Type/Value

Description

fileData?

Boolean

For resources that contain a file, set this argument to true to download the file. When not specified, this argument is false by default and the method returns the description of the resource.

IC_GET_QUERY_DATA?

String

Used to get the items to fill an input control which subtend a query resource. The value of this parameter must be the URI of the data source to use to execute the query. Set the null string to use the default data source.

P_<param name>?

String

If the IC_GET_QUERY_DATA is specified, one or more parameters can be specified to be used in the query:

Use the "P_" prefix for single values.
Use the "PL_" prefix for list of values.

PL_<param name>?

String

Return Value on Success

Typical Return Values on Failure

200 OK – The body is either:

XML giving the resourceDescriptors that make up the resource, including nested descriptors.
The native content of the specified file.

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

The GET method returns the structure and definition of resources in the repository, and using that information can be used to download any files attached to the resources. Resources are defined through resourceDescriptor tags in XML.

The following example shows the resource descriptor of a folder:

<resourceDescriptor name="datasources" wsType="folder" uriString="/datasources"
                    isNew="false">
  <label>Data Sources</label>
  <description>Data Sources used by reports</description>
  <creationDate>1317838605320</creationDate>
  <resourceProperty name="PROP_RESOURCE_TYPE">
    <value>com.jaspersoft.jasperserver.api.metadata.common.domain.Folder</value>
  </resourceProperty>
  <resourceProperty name="PROP_PARENT_FOLDER"><value>/</value></resourceProperty>
  <resourceProperty name="PROP_VERSION"><value>0</value></resourceProperty>
  <resourceProperty name="PROP_HAS_DATA"><value>false</value></resourceProperty>
</resourceDescriptor>

The following example shows the resource descriptor of a data source. The various resourceProperty tags define the properties of the data source, specific to the JNDI type:

<resourceDescriptor name="SugarCRMDataSourceJNDI" wsType="jndi"
  uriString="/analysis/datasources/SugarCRMDataSourceJNDI" isNew="false">
  <label>SugarCRM Data Source JNDI</label>
  <description>SugarCRM Data Source JNDI</description>
  <creationDate>1318380229907</creationDate>
  <resourceProperty name="PROP_RESOURCE_TYPE">
    <value>com.jaspersoft.jasperserver.api.metadata.jasperreports.domain.
           JndiJdbcReportDataSource</value>
  </resourceProperty>
  <resourceProperty name="PROP_PARENT_FOLDER"><value>/analysis/datasources</value>
  </resourceProperty>
  <resourceProperty name="PROP_VERSION"><value>0</value></resourceProperty>
  <resourceProperty name="PROP_DATASOURCE_JNDI_NAME"><value>jdbc/sugarcrm</value>
  </resourceProperty>
</resourceDescriptor>

The following example shows the resource descriptor of a query resource, with properties for the query string and query language:

<resourceDescriptor name="CustomerCityQuery" wsType="query"
  uriString="/datatypes/CustomerCityQuery" isNew="false">
  <label>Customer City Query</label>
  <description>Retrieves names of all customers' home cities</description>
  <creationDate>1318380317602</creationDate>
  <resourceProperty name="PROP_RESOURCE_TYPE">
    <value>com.jaspersoft.jasperserver.api.metadata.common.domain.Query</value>
  </resourceProperty><resourceProperty name="PROP_PARENT_FOLDER">
    <value>/JUNIT_NEW_FOLDER</value></resourceProperty>
  <resourceProperty name="PROP_VERSION"><value>0</value></resourceProperty>
  <resourceProperty name="PROP_HAS_DATA"><value>false</value></resourceProperty>
  <resourceProperty name="PROP_IS_REFERENCE"><value>false</value></resourceProperty>
  <resourceProperty name="PROP_QUERY">
    <value>select distinct customer.city from customer</value></resourceProperty>
  <resourceProperty name="PROP_QUERY_LANGUAGE"><value>sql</value></resourceProperty>
</resourceDescriptor>
Version: 
Feedback
randomness