Jump to content
  • Using REST v2's PATCH method to modify the "resource" field of a ReportUnit


    bnee_1
    • Version: v6.0 Product: JasperReports® Server

    Issue Description

    I have an existing ReportUnit resource that I would like to modify using the REST v2 API. When I attempted to update the "resources" field of this ReportUnit like this:

    [toc]
    {
     "version":0,
     "patch":[ { "field":"resources", "value":"[URI OF RESOURCE HERE]"
               } ]
    }
    

    I got the error:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    
        <errorDescriptor>
            <errorCode>patch.failed</errorCode>
            <message>
                EL1010E:(pos 0): Field or property resources cannot be set on object of type com.jaspersoft.jasperserver.dto.resources.ClientReportUnit
            </message>
        <parameters>
            <parameter>
                resources = &quot;[URI OF RESOURCE HERE]&quot;
            </parameter>
        </parameters>
    </errorDescriptor>
    

    Resolution

    Use this JSON syntax:

    {
     "version":0,
     "patch":[ { "expression": "files.put('test_file', new com.jaspersoft.jasperserver.dto.resources.ClientReference().setUri('/public/Samples/Resources/Images/ico-library.jpg'))"
               } ]
    }
    

    "files" is used instead of "resources" because ClientReportUnit doesn't have any "resources" field.

    It has a "files" field, which is java.util.Map, and it's being mapped to "resources" for convenience.

    You can look in our jasperserver-dto package to see the actual Java structure of classes to patch.

    The PATCH Method was introduced in JasperReports Server v5.5, and it is discussed in the Web Services Guide PDF that comes with JasperReports Server.


    Ref. Case 00057949


    User Feedback

    Recommended Comments

    There are no comments to display.



    Guest
    This is now closed for further comments

×
×
  • Create New...