Creating a Resource

The PUT method on the resource service is used to create a new resource. If the resource has one or more file resources, they must be provided using a multipart request.










This parameter identifies the part with an XML resource descriptor in a multipart request. This is a required argument when using multipart requests.




text/plain (in the first part)

application/octet-stream (for files)

A well-formed XML resourceDescriptor that fully describes the resource, including any locally defined resources. File resources are uploaded in separate parts.

Return Value on Success

Typical Return Values on Failure

201 Created – The body is XML containing the resourceDescriptor of the resource just created.

An error if the resource cannot be created for some reason. If you have very large files, see section Setting the Temporary Upload Directory.

In the following sample request, the URI is the location where we want to create the resource, in this case / (the root), and the content includes the resource descriptor for a new folder called myfolder.

PUT /jasperserver/rest/resource/ HTTP/1.1
Content-Length: 473
Content-Type: multipart/form-data; boundary=1afdzzMUQLfSOmu0Pgb2F-nmEnTwWuPf3
Host: localhost:8080
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)
Cookie: JSESSIONID=3370EC843B09363C0A8DD09A2D1F21E3
Cookie2: $Version=1
Content-Disposition: form-data; name="ResourceDescriptor"
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 8bit
<resourceDescriptor name="myfolder" wsType="folder" uriString="/myfolder"
  <label>REST created folder</label>
  <resourceProperty name="PROP_PARENT_FOLDER">

Also, the example above shows a multi-part request even though it is only sending the plain-text resource descriptor and not a binary file. Usually, such requests could be sent without multiple parts, and multiple parts are used to send a binary file, for example when creating a report.

When the ResourceDescriptor contains the ResourceProperty PROP_PARENT_FOLDER, that property overrides the path/to/resource given as the URL and determines the location of the new resource.

The response to the PUT request is the complete resource descriptor for the new folder:

HTTP/1.1 201 Created
Server: Apache-Coyote/1.1
Cache-Control: no-cache
Content-Length: 648
Date: Mon, 01 Aug 2011 14:44:05 GMT
<resourceDescriptor name="myfolder" wsType="folder" uriString="/myfolder"
  <label>REST created folder</label>
  <resourceProperty name="PROP_RESOURCE_TYPE">
  <resourceProperty name="PROP_PARENT_FOLDER">
  <resourceProperty name="PROP_VERSION">
  <resourceProperty name="PROP_HAS_DATA">