The resources Service

The resources service lets you browse or search the repository. When used without arguments, it gives the list of resources in the folder specified in the URL. With the arguments, you can search for terms in the resource names or descriptions, search for all resources of a given type, and specify whether to search in subfolders. This service is similar to the list operation in the SOAP web services.

The resources service is a read only service. Requests for PUT, POST, and DELETE operations receive the error 405, method not allowed.

Method

URL

GET

http://<host>:<port>/jasperserver[-pro]/rest/resources/path/to/folder/

Argument

Type/Value

Description

q?

String

Match only resources having the specified text in the name or description. Note that the search string does not match in the ID of resources.

type?

wsType

Match only resources of the given type. Valid types are listed in Values for wsType, for example: datasource, reportUnit, img, folder.

Searching by type does not always yield the expected results when using newer versions of the server (5.0 and later). New repository types may appear unexpectedly in the results. The v2/resources service resolves this issue, but the (v1) resources service is deprecated and will no longer be updated.

recursive?

0 | 1

Search for resources recursively and not only in the specified folder. This parameter is used only when a search criteria is specified (either q or type). When not specified, the default is 0, meaning only in the specified folder.

Note that searching recursively in the whole repository may cause performance issues, because the number of resources returned may be huge.

limit?

Integer >= 0

Maximum number of items returned to the client. The default is 0, meaning no limit.

Return Value on Success

Typical Return Values on Failure

200 OK – The body is XML containing the list of resourceDescriptors.

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

The XML content in the result consists of resourceDescriptors described in section Syntax of resourceDescriptor. However, the list may be empty in the following conditions:

If the specified URI is a resource instead of a folder.
If the folder is empty or the search returns no results.

The following example shows the request to list the resources in the /reports folder:

GET /jasperserver/rest/resources/reports HTTP/1.1
User-Agent: Jakarta Commons-HttpClient/3.1
Authorization: Basic amFzcGVyYWRtaW46amFzcGVyYWRtaW4=
Host: localhost:8080
Cookie: $Version=0; JSESSIONID=6854BF45EC89F3D3CE3E6F4FD6FF1BBD; $Path=/jasperserver

Because the example is not a recursive search, it simply returns the contents of the folder, in this case a subfolder and a report:

HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Pragma: No-cache
Cache-Control: no-cache
Expires: Thu, 01 Jan 1970 01:00:00 CET
Content-Length: 1518
Date: Fri, 24 Jun 2011 12:09:45 GMT
<resourceDescriptors>
  <resourceDescriptor name="samples" wsType="folder" uriString="/reports/samples"
                      isNew="false">
    <label>Samples</label>
    <description>Samples</description>
    <creationDate>1302268917000</creationDate>
    <resourceProperty name="PROP_HAS_DATA"><value>false</value></resourceProperty>
    <resourceProperty name="PROP_RESOURCE_TYPE">
      <value>com.jaspersoft.jasperserver.api.metadata.common.domain.Folder</value>
    </resourceProperty>
    <resourceProperty name="PROP_PARENT_FOLDER"><value>/reports</value>
    </resourceProperty>
    <resourceProperty name="PROP_SECURITY_PERMISSION_MASK"><value>31</value>
    </resourceProperty>
    <resourceProperty name="PROP_VERSION"><value>0</value></resourceProperty>
  </resourceDescriptor>
  <resourceDescriptor name="test" wsType="reportUnit" uriString="/reports/test"
                      isNew="false">
    <label>A test</label>
    <creationDate>1303206124000</creationDate>
    <resourceProperty name="PROP_RESOURCE_TYPE">
      <value>com.jaspersoft.jasperserver.api.metadata.jasperreports.domain.
             ReportUnit</value>
    </resourceProperty>
    <resourceProperty name="PROP_PARENT_FOLDER"><value>/reports</value>
    </resourceProperty>
    <resourceProperty name="PROP_SECURITY_PERMISSION_MASK"><value>31</value>
    </resourceProperty>
    <resourceProperty name="PROP_VERSION"><value>19</value></resourceProperty>
    <resourceProperty name="PROP_RU_ALWAYS_PROPMT_CONTROLS"><value>true</value>
    </resourceProperty>
    <resourceProperty name="PROP_RU_CONTROLS_LAYOUT"><value>1</value>
    </resourceProperty>
  </resourceDescriptor>
</resourceDescriptors>

The following sample request is intended to list all the reports available in the /reports folder and subfolders. The result, not shown, is a long list of resourceDescriptors for reports in the designated folders.

GET /jasperserver/rest/resources/reports?type=reportUnit&recursive=1 HTTP/1.1
User-Agent: Jakarta Commons-HttpClient/3.1
Authorization: Basic amFzcGVyYWRtaW46amFzcGVyYWRtaW4=
Host: localhost:8080
Cookie: $Version=0; JSESSIONID=60B573BDC47098E6379FC867B24C5C0E; $Path=/jasperserver
Version: 
Feedback
randomness