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:
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 accountSign in
Already have an account? Sign in here.
Sign In Now