How to request a jasper report with POST

0

I don't want to send the report parameters in the browser URL like this:

/jasperserver/flow.html?_flowId=viewReportFlow&_flowId=viewReportFlow&ParentFolderUri=%2FPublished&reportUnit=%2FPublished%2FUser_Report&decorate=no&standAlone=true

I'm very interested to do POST requests and display it in the same jasper server report viewer as always.

Is this posible ?

danielsl9.dp's picture
Joined: May 10 2021 - 8:35am
Last seen: 4 days 11 hours ago

1 Answer:

1

Yes, Jaspersoft Server's REST API allows for report execution with POST using the reportExecutions service.

I've attached the following HTTP request sample of this using Postman.  The first request is a synchronous request to execute the report.  It returns the necessary request and export information.  The second request retrieves the report output from the previous execution.  You can choose to run an asynchronous request for longer running reports if preferred.

POST /jasperserver-pro79/rest_v2/reportExecutions HTTP/1.1
Host: localhost:8080
Authorization: Basic c3VwZXJ1c2VyOnN1cGVydXNlcg==
Content-Type: application/xml
Cookie: userLocale=en_US; JSESSIONID=9E0BBE880F49C7987CAE6C4E43252641
Content-Length: 509
 
<reportExecutionRequest>
    <reportUnitUri>/public/Samples/Reports/01._Geographic_Results_by_Segment_Report</reportUnitUri>
    <async>false</async>
    <freshData>false</freshData>
    <saveDataSnapshot>false</saveDataSnapshot>
    <outputFormat>html</outputFormat>
    <interactive>true</interactive>
    <ignorePagination>true</ignorePagination>
    <parameters>
        <reportParameter name="Country">
            <value>USA</value>
        </reportParameter>
    </parameters>
</reportExecutionRequest>
GET /jasperserver-pro79/rest_v2/reportExecutions/ad0edbf2-abd2-4ebe-8344-b2e453eab496/exports/79662286-aa90-4e98-a732-337ab5ee0504/outputResource HTTP/1.1
Host: localhost:8080
Authorization: Basic c3VwZXJ1c2VyOnN1cGVydXNlcg==
Cookie: userLocale=en_US; JSESSIONID=9E0BBE880F49C7987CAE6C4E43252641

jabrown's picture
214
Joined: Sep 3 2017 - 10:08pm
Last seen: 2 weeks 4 days ago
Feedback
randomness