Is it possible to publish a japser report (JRXML file) with command line prompt ?

0

Hello everybody !

I was wondering if it was possible to publish a report to the JasperReports Server with the command line, it could be very usefull to me !

Thanks in advance for helping.

jeanpierrepolnareff91's picture
Joined: May 22 2019 - 1:10am
Last seen: 1 day 8 hours ago

1 Answer:

0

Hi jean-pierre !

You can publish reports with the REST API,  go to this documentation (https://community.jaspersoft.com/wiki/how-use-rest-v2-upload-report-unit-jasperreports-server-base64-encode-approach) for more information.

Example of a shell script right here : 

#put all the jrxml into a variable

JRXML_DATA_1=$(cat ../select_acti.jrxml) 

#curl command to publish the jrxml file

curl  -X POST http://your_server:8080/jasperserver-pro/rest_v2/resources/path_where_you_want_to_put_the_report -H "Content-Type:application/jrxml" -H "Content-Disposition:attachment; filename=name_of_the_jrxml_file" -H "Content-Description:your description" -d "$JRXML_DATA_1" --user username:password

#load a reportUnit into a variable :

RESOURCEDESCRIPTOR_XML_1=$(cat ../select_acti_reportUnit.xml)

#curl command to create the reportUnit

curl -X POST http://your_server:8080/jasperserver-pro/rest_v2/resources/path -H "Content-Type:application/repository.reportUnit+xml" -d "$RESOURCEDESCRIPTOR_XML_1" --user username:password

 

example of reportUnit file : 

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<reportUnit>
    <description></description>
    <label>select_acti</label>
    <permissionMask>1</permissionMask>
    <uri>/path/select_acti</uri>
    <version>0</version>
    <dataSourceReference>
        <uri>/datasource_path</uri>
    </dataSourceReference>
    <alwaysPromptControls>true</alwaysPromptControls>
    <controlsLayout>popupScreen</controlsLayout>
    <inputControlRenderingView></inputControlRenderingView>
    <jrxmlFileReference>
        <uri>/path/select_acti_jrxml</uri>
    </jrxmlFileReference>
</reportUnit>

Best regards,

Arnaud

arnaudsimon091's picture
Joined: Nov 26 2018 - 12:25pm
Last seen: 1 week 4 days ago
Feedback