Jump to content
We've recently updated our Privacy Statement, available here ×

Passing Report Parameters using RESTFul Service


mick1027

Recommended Posts

Hi, The documentation ( pg 30 of JASPERREPORTS SERVER
WEB SERVICES GUIDE 4.2 )

The body of the PUT request should contain a resource descriptor of type reportUnit with the URI of the report unit to run.
The resource descriptor can contain one or more parameter tags to specify parameters. Lists can be passed using parameters
with the same name and the isListValue attribute set to true.
The arguments can be placed in the URL of the request or by encoding them in the multipart request. However, some
application servers such as Apache Tomcat do not process arguments that are www-url-encoded in the request when sent to a
PUT method, so be sure you are using a multipart request or you are using the GET style parameters when using this method.

I read this and was not clear on what XML elements to use for passing parameters..

Does anyone have an example of passing report parameters utilizing a RESTful service? I would like to set this up in the body of the PUT that woudl generate the report.

How would I setup up the XML in the below example?

<?xml version="1.0" encoding="UTF-8"?><resourceDescriptor isNew="false" name="test_report" uriString="/organizations/organization_1/Reports1/test_report" wsType="reportUnit">
    <label><![CDATA[test_report]]></label>
    <creationDate>1317157868000</creationDate>
    <resourceProperty name="PROP_RESOURCE_TYPE">
        <value><![CDATA[com.jaspersoft.jasperserver.api.metadata.jasperreports.domain.ReportUnit]]></value>
    </resourceProperty>
    <resourceProperty name="PROP_PARENT_FOLDER">
        <value><![CDATA[/organizations/organization_1/Reports1]]></value>
    </resourceProperty>
    <resourceProperty name="PROP_VERSION">
        <value><![CDATA[3]]></value>
    </resourceProperty>
    <resourceProperty name="PROP_RU_ALWAYS_PROPMT_CONTROLS">
        <value><![CDATA[true]]></value>
    </resourceProperty>
    <resourceProperty name="PROP_RU_CONTROLS_LAYOUT">
        <value><![CDATA[1]]></value>
    </resourceProperty>
    <resourceProperty name="PROP_RU_INPUTCONTROL_RENDERING_VIEW">
        <value/>
    </resourceProperty>
</resourceDescriptor>

 

Thanks!



Post Edited by mick1027 at 01/31/2012 13:34
Link to comment
Share on other sites

  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

found the answer to my question.. Something like this works:

 

<?xml version="1.0" encoding="UTF-8"?><resourceDescriptor isNew="false" name="Report1" uriString="/organizations/organization_1/Reports1/Report1" wsType="reportUnit">
        <label><![CDATA[report_1]]></label>
    <creationDate>1317135409000</creationDate>
    <parameter name ="exampleParm1" >10</parameter>
    <parameter name ="exampleParm2" >011010</parameter>

    <resourceProperty name="PROP_RESOURCE_TYPE">
        <value><![CDATA[com.jaspersoft.jasperserver.api.metadata.jasperreports.domain.ReportUnit]]></value>
    </resourceProperty>
    <resourceProperty name="PROP_PARENT_FOLDER">
        <value><![CDATA[/organizations/organization_1/Reports1]]></value>
    </resourceProperty>
    <resourceProperty name="PROP_VERSION">
        <value><![CDATA[5]]></value>
    </resourceProperty>
    <resourceProperty name="PROP_RU_ALWAYS_PROPMT_CONTROLS">
        <value><![CDATA[true]]></value>
    </resourceProperty>
    <resourceProperty name="PROP_RU_CONTROLS_LAYOUT">
        <value><![CDATA[1]]></value>
    </resourceProperty>
    <resourceProperty name="PROP_RU_INPUTCONTROL_RENDERING_VIEW">
        <value/>
    </resourceProperty>
</resourceDescriptor>

Link to comment
Share on other sites

  • 3 months later...

HI

I am also using the Jrxml queryString and RestTemplate PUT methd call.

In My Jrxml file I have witten a simple query using where clause as below.

Select * from Employer where emp_id=$P{id}.

And I am passing the parameter using <parameter> tag as below:

<?xml version="1.0" encoding="UTF-8"?>
<resourceDescriptor name="testList" wsType="reportUnit" uriString="/Reports/testList" isNew="false">
    <label><![CDATA[testList]]></label>
    <creationDate>1336714867000</creationDate>


<parameter name ="id" >10</parameter>


    <resourceProperty name="PROP_RESOURCE_TYPE">
        <value><![CDATA[com.jaspersoft.jasperserver.api.metadata.jasperreports.domain.ReportUnit]]></value>
    </resourceProperty>
    <resourceProperty name="PROP_PARENT_FOLDER">
        <value><![CDATA[/Reports]]></value>
    </resourceProperty>
    <resourceProperty name="PROP_VERSION">
        <value><![CDATA[0]]></value>
    </resourceProperty>
    <resourceProperty name="PROP_RU_ALWAYS_PROPMT_CONTROLS">
        <value><![CDATA[false]]></value>
    </resourceProperty>
    <resourceProperty name="PROP_RU_CONTROLS_LAYOUT">
        <value><![CDATA[1]]></value>
    </resourceProperty>
    <resourceDescriptor name="testList_" wsType="jrxml" uriString="/Reports/testList_files/testList_" isNew="false">
        <label><![CDATA[testList]]></label>
        <creationDate>1336714867000</creationDate>
        <resourceProperty name="PROP_RESOURCE_TYPE">
            <value><![CDATA[com.jaspersoft.jasperserver.api.metadata.common.domain.FileResource]]></value>
        </resourceProperty>
        <resourceProperty name="PROP_PARENT_FOLDER">
            <value><![CDATA[/Reports/testList_files]]></value>
        </resourceProperty>
        <resourceProperty name="PROP_VERSION">
            <value><![CDATA[0]]></value>
        </resourceProperty>
        <resourceProperty name="PROP_IS_REFERENCE">
            <value><![CDATA[false]]></value>
        </resourceProperty>
        <resourceProperty name="PROP_HAS_DATA">
            <value><![CDATA[true]]></value>
        </resourceProperty>
        <resourceProperty name="PROP_ATTACHMENT_ID">
            <value><![CDATA[attachment]]></value>
        </resourceProperty>
        <resourceProperty name="PROP_RU_IS_MAIN_REPORT">
            <value><![CDATA[true]]></value>
        </resourceProperty>
    </resourceDescriptor>
</resourceDescriptor>
 

When I call a put method I am getting error like

Report design not valid :
     1. Query parameter not found : id

I am using Jasper server 4.5 and IDE is Spring STS (Eclipse).

Can anyone please help me on this.I have also attached my jrxml file.

Your early response is highly appreciable.

 

Thanks

Pratap Panda

 

 

 

 

 

 



Post Edited by saypratap at 05/11/2012 13:09
Link to comment
Share on other sites

  • 1 month later...

 Can you let me know how you're reading the parameters from the resource descriptor?

I make a GET call to get the list of resources/reports at a path. The list is returned as resource descriptor but I do not see the parameters in the resource descriptor.

In my Java code, when I do a getParameters() against the resource descriptor object it gives me null even when I know a report does have a parameter.

Any clue?

Link to comment
Share on other sites

  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...