Modifying a Resource

Use the PUT method above to overwrite an entire resource. Specify the path of the target resource in the URL and specify resource of the same type. Use overwrite=true to replace a resource of a different type.

The resource descriptor must completely describe the updated resource, not use individual fields. The descriptor must also use only references for nested resources, not other resources expanded inline. You can update the local resources using the hidden folder _file. For more informations, see Modifying a Resource.

In JasperReports Server 5.5, Jaspersoft introduces a new method for modifying resoures. The PATCH method updates individual descriptor fields on the target resource. It also accept expressions that modify the descriptor in the Spring Expression Language. This expression language lets you easily modify the structure and values of descriptors.

Method

URL

PATCH

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

Content-Type

Content

application/json

{
    "version" : 0,
    "patch":[
        {
            "field":"label",
            "value":"New Label"
        },
        {
            "field":"query",
            "value":"/path/to/query/resource"
        },
        {
            "expression":"inputControls.add(new com.jaspersoft.
                jasperserver.dto.resources.ClientReference().
                setUri('/datatypes/decorate'))"
        }
    ]
}

application/xml

<patchItems>
  <version>0</version>
    <patch>
        <field>label</field>
        <value>New Label</value>
    </patch>
    <patch>
        <field>query</field>
        <value>/path/to/query/resource</value>
    </patch>
    <patch>
        <expression>inputControls.add(new com.jaspersoft.
            jasperserver.dto.resources.ClientReference().
            setUri('/datatypes/decorate'))
        </expression>
    </patch>
</patchItems>

Return Value on Success

Typical Return Values on Failure

For confirmation, the response contains the full descriptor of the resource that was just modified.

400 Bad Request – Mismatch between the patch fields and the fields or syntax of the actual descriptor.

409 Conflict – Old version number; the resource was updated more recently than the last version number received.

The patch descriptor contains attributes of the target resource. It can't be used to specify the attributes of nested resources. However, you can apply the patch operation directly to the local resource in the hidden _files folder.

If your client does not support the PATCH method, use the POST method and specify the following HTTP header:

X-HTTP-Method-Override: PATCH

Version: 
Feedback
randomness