Requesting the Contents of a JasperReport

A JasperReport is a complex resource that contains many parts such as a data source, input controls, and file resources. These can be either references to other resources in the repository or resources that are fully defined internally to the report.

In the following example, a simple request gives the contents of a JasperReport:

GET http://localhost:8080/jasperserver/rest/resource/reports/samples/AllAcco...

The following response in this example shows the content of the AllAccounts report:

The reportUnit, which is the container for all the resources of the report.
The data source, which is an external link to a data source in the repository.
The main JRXML, which is a file defined internally to this resource.
Two image files, one of which is defined internally to this resource, the other references a file resource in the repository.

The structure of the JasperReport is defined through nested resourceDescriptor tags in XML. In the nested descriptor for each file that is part of the JasperReport, we can find its URI and use fileData=true to retrieve that file:

<resourceDescriptor name="AllAccounts" wsType="reportUnit"
                    uriString="/reports/samples/AllAccounts" isNew="false">
  <label>Accounts Report</label>
  <description>All Accounts Report</description>
  <creationDate>1302268918000</creationDate>
  <resourceProperty name="PROP_RESOURCE_TYPE">
    <value>com.jaspersoft.jasperserver.api.metadata.jasperreports.domain.
           ReportUnit</value>
  </resourceProperty>
  <resourceProperty name="PROP_PARENT_FOLDER"><value>/reports/samples</value>
  </resourceProperty>
  <resourceProperty name="PROP_VERSION"><value>2</value></resourceProperty>
  <resourceProperty name="PROP_RU_ALWAYS_PROPMT_CONTROLS"><value>false</value>
  </resourceProperty>
  <resourceProperty name="PROP_RU_CONTROLS_LAYOUT"><value>1</value>
  </resourceProperty>
  <resourceDescriptor name="" wsType="datasource" uriString="" isNew="false">
    <label>null</label>
    <resourceProperty name="PROP_REFERENCE_URI">
      <value>/datasources/JServerJNDIDS</value>
    </resourceProperty>
    <resourceProperty name="PROP_IS_REFERENCE"><value>true</value>
    </resourceProperty>
  </resourceDescriptor>
  <resourceDescriptor name="AllAccountsReport" wsType="jrxml" uriString="/reports/
samples/AllAccounts_files/AllAccountsReport" isNew="false">
    <label>All Accounts Jasper Report</label>
    <description>All Accounts Jasper Report</description>
    <creationDate>1302268918000</creationDate>
    <resourceProperty name="PROP_RESOURCE_TYPE">
      <value>com.jaspersoft.jasperserver.api.metadata.common.domain.FileResource
</value>
    </resourceProperty>
    <resourceProperty name="PROP_PARENT_FOLDER">
      <value>/reports/samples/AllAccounts_files</value>
    </resourceProperty>
    <resourceProperty name="PROP_VERSION"><value>2</value></resourceProperty>
    <resourceProperty name="PROP_IS_REFERENCE"><value>false</value>
    </resourceProperty>
    <resourceProperty name="PROP_HAS_DATA"><value>true</value></resourceProperty>
    <resourceProperty name="PROP_ATTACHMENT_ID"><value>attachment</value>
    </resourceProperty>
    <resourceProperty name="PROP_RU_IS_MAIN_REPORT"><value>true</value>
    </resourceProperty>
  </resourceDescriptor>
  <resourceDescriptor name="AllAccounts_Res2" wsType="img" uriString="/reports/
samples/AllAccounts_files/AllAccounts_Res2" isNew="false">
    <label>AllAccounts_Res2</label>
    <description>AllAccounts_Res2</description>
    <creationDate>1302268918000</creationDate>
    <resourceProperty name="PROP_RESOURCE_TYPE">
      <value>com.jaspersoft.jasperserver.api.metadata.common.domain.FileResource
</value>
    </resourceProperty>
    <resourceProperty name="PROP_PARENT_FOLDER">
      <value>/reports/samples/AllAccounts_files</value></resourceProperty>
    <resourceProperty name="PROP_VERSION"><value>0</value></resourceProperty>
    <resourceProperty name="PROP_IS_REFERENCE"><value>false</value>
    </resourceProperty>
    <resourceProperty name="PROP_HAS_DATA"><value>true</value></resourceProperty>
    <resourceProperty name="PROP_ATTACHMENT_ID"><value>attachment</value>
    </resourceProperty>
  </resourceDescriptor>
  <resourceDescriptor name="AllAccounts_Res3" wsType="img" uriString="/reports/
samples/AllAccounts_files/AllAccounts_Res3" isNew="false">
    <label>AllAccounts_Res3</label>
    <description>AllAccounts_Res3</description>
    <creationDate>1302268918000</creationDate>
    <resourceProperty name="PROP_RESOURCE_TYPE">
      <value>com.jaspersoft.jasperserver.api.metadata.common.domain.FileResource
</value></resourceProperty>
    <resourceProperty name="PROP_PARENT_FOLDER">
      <value>/reports/samples/AllAccounts_files</value></resourceProperty>
    <resourceProperty name="PROP_VERSION"><value>0</value></resourceProperty>
    <resourceProperty name="PROP_IS_REFERENCE"><value>false</value>
    </resourceProperty>
    <resourceProperty name="PROP_HAS_DATA"><value>true</value></resourceProperty>
    <resourceProperty name="PROP_ATTACHMENT_ID"><value>attachment</value>
    </resourceProperty>
  </resourceDescriptor>
  <resourceDescriptor name="LogoLink" wsType="reference" uriString="/reports/
                      samples/AllAccounts_files/LogoLink" isNew="false">
    <label>LogoLink_label</label>
    <description>LogoLink description</description>
    <creationDate>1302268918000</creationDate>
    <resourceProperty name="PROP_RESOURCE_TYPE">
      <value>com.jaspersoft.jasperserver.api.metadata.common.domain.FileResource
      </value></resourceProperty>
    <resourceProperty name="PROP_PARENT_FOLDER">
      <value>/reports/samples/AllAccounts_files</value></resourceProperty>
    <resourceProperty name="PROP_VERSION"><value>0</value></resourceProperty>
    <resourceProperty name="PROP_IS_REFERENCE"><value>true</value>
    </resourceProperty>
    <resourceProperty name="PROP_REFERENCE_URI"><value>/images/JRLogo</value>
    </resourceProperty>
    <resourceProperty name="PROP_HAS_DATA"><value>true</value></resourceProperty>
    <resourceProperty name="PROP_ATTACHMENT_ID"><value>attachment</value>
    </resourceProperty>
  </resourceDescriptor>
</resourceDescriptor>
Version: 
Feedback
randomness