Search code examples
restjasperserver

Patch the datasource of a report using rest_v2 in jasperServer


I am trying to change the data source of a report using this url with the Patch option:

http://localhost:8081/jasperserver/rest_v2/resources/reports/report

using as a body :

{
    "version" : 1,
    "patch":[
        {
        "expression":"dataSource.add(new com.jaspersoft.jasperserver.dto.resources.ClientReference().setUri('/datasources/dataTest'))"
        }
    ]
}

I am getting the following error:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<errorDescriptor>
    <errorCode>patch.failed</errorCode>
    <message>EL1004E:(pos 11): Method call: Method add(com.jaspersoft.jasperserver.dto.resources.ClientReference) cannot be found on com.jaspersoft.jasperserver.dto.resources.ClientReference type</message>
    <parameters>
        <parameter>dataSource.add(new com.jaspersoft.jasperserver.dto.resources.ClientReference().setUri('/datasources/dataTest'))</parameter>
    </parameters>
</errorDescriptor>

I don't know how to do it.

Thanks in advance.


Solution

  • To solve the issue I have sent in the body the following:

    {
        "version": "1",
        "patch": [{
            "field": "dataSource",
            "value": "/datasources/dataTest"
        }]
    }