Jump to content
We've recently updated our Privacy Statement, available here ×
  • REST_v2 Sample: Creating a Report Unit with Resource file and Input Control using JSON format


    vchiem
    • Features: JasperReports Server, Reports Version: v7 Product: Jaspersoft Java REST Client

    Below are the sample JSON constructs for adding a resource file (such as "Logo.png") and an Input control ("Stmt_Date") to a newly created Report Unit ("TESTREPORT").  

    Request:

    POST http://<server>:8080/jasperserver-pro/rest_v2/resources/Reports

    Authorization
    username: jasperadmin|Test (Note: 'Test' is an Organization)
    password: jasperadmin 

    Headers:
    Accept: application/json
    Content-Type: application/repository.reportUnit+json

    1> After adding the resource file to a repository folder eg. /public

    REST BODY:

    {
        "label": "TESTREPORT",
        "dataSource": {
            "dataSourceReference": {
                "uri": "/public/DataSources/foodmart_jdbc"
            }
        },
    
    "query": null,
    "inputControlRenderingView": "",
    "reportRenderingView": "",
    "alwaysPromptControls": true,
    "controlsLayout": "popupScreen",
    
     "inputControls": [
            {
                "inputControl": {
                    "label": "Stmt_Date",
                    "mandatory": false,
                    "readOnly": false,
                    "visible": true,
                    "type": 2,
                    "dataType": {
                        "dataType": {
                            "label": "myDatatype",
                            "type": "date",
                            "strictMax": false,
                            "strictMin": false
                        }
                    }
               }
            }
        ],  
    
        "resources": {
            "resource": [
                {
                    "name": "Logo",
                    "file": {
                        "fileReference": {
                            "uri": "/public/Logo.png"
                        }
                    }
                }
            ]
        },
    
        "jrxml": {
            "jrxmlFile": {
                "type": "jrxml",
                "label": "mainReport",
                "content": "<base64 encoded content>"
            }
        }
    }


    2> When resource file is added as a base64 encoded content (not residing in the repository)

    REST BODY:

    {
        "label": "TESTREPORT",
        "dataSource": {
            "dataSourceReference": {
                "uri": "/public/DataSources/foodmart_jdbc"
            }
        },
    
    "query": null,
    "inputControlRenderingView": "",
    "reportRenderingView": "",
    "alwaysPromptControls": true,
    "controlsLayout": "popupScreen",
    
     "inputControls": [
            {
                "inputControl": {
                    "label": "Stmt_Date",
                    "mandatory": false,
                    "readOnly": false,
                    "visible": true,
                    "type": 2,
                    "dataType": {
                        "dataType": {
                            "label": "myDatatype",
                            "type": "date",
                            "strictMax": false,
                            "strictMin": false
                        }
                    }
               }
            }
        ],  
    
      "resources": {
            "resource": [
                {
                    "name": "Logo",
                    "file": {
                        "fileResource": {
                        "label": "Logo.png",
                        "type": "img",
                        "content": "<base64 encoded content of logo.png>"
                        }
                    } 
                }   
            ]   
            
        },
    
        "jrxml": {
            "jrxmlFile": {
                "type": "jrxml",
                "label": "mainReport",
                "content": "<base64 encoded content of jrxml file>"
            }
        }
    }

    Screenshot of the Report Unit created:

    reportunit.jpg.9c57be766a61aaf557346f00fa4a07df.jpg

     

    report_unit.postman_collection.json


    User Feedback

    Recommended Comments

    There are no comments to display.



    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...