How to deploy a report (jrxml file) through the Jasper PHP/REST API?

后端 未结 2 832
伪装坚强ぢ
伪装坚强ぢ 2021-01-07 12:43

How to deploy a report (jrxml file) through the Jasper PHP/REST API to the Jasper Reports Server?

2条回答
  •  再見小時候
    2021-01-07 13:21

    For deploying Jasper reports on Jasper Server using Rest-API you can use following method:

    Uploading JRXML file

    JRXML_DATA=$(cat $PATHTOJRXMLFILE/$JRXML_FILE)
    
    curl  -X POST $JASPER_REST_HOST/jasperserver/rest_v2/resources/reports \
    -H "Content-Type:application/jrxml" \
    -H "Content-Disposition:attachment; filename=test" \
    -H "Content-Description:test file" \
    -d "$JRXML_DATA" \
    --user $JASPER_USERNAME:$JASPER_USERNAME
    

    Creating ReportUnit

    RESOURCEDESCRIPTOR_JSON=$(cat $REPORT/deployable/reportunit.json)
    
    curl  -X POST $JASPER_REST_HOST/jasperserver/rest_v2/resources/reports \
    -H "Content-Type:application/repository.reportUnit+json" \
    -d "$RESOURCEDESCRIPTOR_JSON" \
    --user $JASPER_USERNAME:$JASPER_PASSWORD
    

    ResourceDescriptor for reportUnit example

    {
        "uri": "/reports/test_report", 
        "label": "test_report", 
        "description": "description", 
        "permissionMask": "0",
        "version": "0" ,
        "alwaysPromptControls": "true",
        "controlsLayout": "popupScreen",
        "jrxml": {
            "jrxmlFileReference": {
                "uri": "/reports/test"
            }
        }
    }
    

    Resource Descriptor references

    http://community.jaspersoft.com/documentation/jasperreports-server-web-services-guide/v56/v2-resource-descriptor-types

提交回复
热议问题