Creating a Resource

The POST and PUT methods offer alternative ways to create resources. Both take a resource descriptor but each handles the URL differently.

With the POST method, specify a folder in the URL, and the new resource ID is created automatically from the label attribute in its descriptor.

Method

URL

POST

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

Parameter

Type/Value

Description

create
Folders

true|false

By default, this is true, and the service will create all parent folders if they don't already exist. When set to false, the folders specified in the URL must all exist, otherwise the service returns an error.

Content-Type

Content

application/repository.

<resourceType>+json

application/repository.

<resourceType>+xml

A well defined descriptor of the specified type and format. See V2 Resource Descriptor Types

Return Value on Success

Typical Return Values on Failure

201 Created – The request was successful and, for confirmation, the response contains the full descriptor of the resource that was just created.

400 Bad Request – Mismatch between the content-type and the fields or syntax of the actual descriptor.

With the PUT method, specify a unique new resource ID as part of the URL. For more information, see Resource IDs.

Method

URL

PUT

http://<host>:<port>/jasperserver[-pro]/rest_v2/resources/path/to/resource
?<parameters>

Parameters

Type/Value

Description

create
Folders

true|false

True by default, and the service will create all parent folders if they don't already exist. When set to false, the folders specified in the URL must all exist, otherwise the service returns an error.

overwrite

true|false

When true, the resource given in the URL is overwritten even if it is a different type than the resource descriptor in the content. The default is false.

Content-Type

Content

application/repository.

<resourceType>+json

application/repository.

<resourceType>+xml

A well defined descriptor of the specified type and format. See V2 Resource Descriptor Types

Return Value on Success

Typical Return Values on Failure

201 Created – The request was successful and, for confirmation, the response contains the full descriptor of the resource that was just created.

400 Bad Request – Mismatch between the content-type and the fields or syntax of the actual descriptor.

The POST method also supports a way to create complex resources and their nested resources in a single multipart request.

Method

URL

POST

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

Content-Type

Content

multipart/form-data

Root resource multipart item name: resource

Root resource multipart Content-type and corresponding item names:

mondrianConnection:

- schema: mondrian schema XML file

secureMondrianConnection:

- schema: mondrian schema XML file

- accessGrantSchemas.accessGrantSchema[{itemIndex}]: XML file

semanticLayerDataSource:

- schema: domain schema XML file

- securityFile: security file XML

- bundles.bundle[{bundleIndex}]: i18n properties file

reportUnit

- jrxml: report unit JRXML file

- files.{fileName}: report unit attached resource file (e.g. images)

Return Value on Success

Typical Return Values on Failure

201 Created – The request was successful and, for confirmation, the response contains the full descriptor of the resource that was just created.

400 Bad Request – Mismatch between the content-type and the fields or syntax of the actual descriptor.

Version: 
Feedback