Jasper Report with RestAPI

狂风中的少年 提交于 2020-01-06 20:25:10

问题


I have a report on JasperServer(5.6) which accepts few parameters. I edit few settings on the Output Options tab and enter emails which i would like to sent to on Notifications tab. The report gets generated successfully and an email is sent out perfectly.

I wish to use the Rest API of JasperServer to pass on my input options and to schedule and email the report. I went through there documentation http://community.jaspersoft.com/documentation/jasperreports-server-web-services-guide/v56/rest-v2-report-services but couldn't understand how to use the rest api.

Here is the properties of my report on the jasper server

Can someone help me out how to schedule my report.


回答1:


Maybe it's can help you: jasperserver rest java client. This is a REST client for Jasperserver.




回答2:


I guess, i have figured out the way to schedule a job on jasper server. Details can be found here

http://community.jaspersoft.com/documentation/tibco-jasperreports-server-web-services-guide/v62/scheduling-report

But as an example here it is (call it with PUT method) http://localhost:8080/jasperserver/rest_v2/jobs and in the body define the job structure


     {
        "id": 3819,
        "version": 2,
        "username": "jasperadmin",
        "label": "publisher_123_report",
        "description": "",
        "creationDate": "2015-12-30T02:02:40.382+03:00",
        "trigger": {
            "simpleTrigger": {
              "id": "1770",
              "misfireInstruction": "0",
              "startDate": "2015-12-20T00:00:00+11:00",
              "startType": "2",
              "timezone": "Australia/Victoria",
              "version": "0",
              "occurrenceCount": "1"
            }
        },
        "source": {
              "reportUnitURI": "/Reports/Prod/test_automated_report_v14",
              "parameters": {
                 "parameterValues": {
                        "PublisherId" : "20",
                       "MonthEnd" : "2015-02-01",
                       "MonthStart" : "2015-03-20",
                       "email" : "admin@admin.com",
                       "CountryCode" : "560"
                 }
              }
        },
        "baseOutputFilename": "publisher_124_automated_report",
        "outputLocale": "",
        "mailNotification": {
            "subject": "publisher monthly report" ,
            "toAddresses": {
                "address": ["address1To@add.com", "address2To@add.com"]
            },
            "ccAddresses": {
                "address": ["address1cc@add.com", "address2cc@add.com"]
            },
            "bccAddresses": {
                "address": ["address1bcc@add.com", "address2bcc@add.com"]
            }, 
            "includingStackTraceWhenJobFails" : false,
            "resultSendType" : "SEND_EMBED",
            "skipEmptyReports" : true,
            "skipNotificationWhenJobFails" : false   
        },
        "alert": {
            "id": 0,
            "version": -1,
            "recipient": "OWNER_AND_ADMIN",
            "toAddresses": {
                "address": ["address1@add.com", "address2@add.com"]
            },
            "jobState": "FAIL_ONLY",
            "messageText": "Success",
            "messageTextWhenJobFails": "Failure",
            "subject": "Notification Subject",
            "includingStackTrace": true,
            "includingReportJobInfo": true,
            "jobState" : "ALL"
        },
        "outputTimeZone": "Australia/Melbourne",
        "repositoryDestination": {
            "id": 3817,
            "version": 0,
            "folderURI": "/Reports/Prod",
            "sequentialFilenames": false,
            "overwriteFiles": false,
            "outputDescription": "",
            "timestampPattern": null,
            "saveToRepository": true,
            "defaultReportOutputFolderURI": null,
            "usingDefaultReportOutputFolderURI": false,
            "outputLocalFolder": null,
            "outputFTPInfo": {
                "userName": null,
                "password": null,
                "folderPath": null,
                "serverName": null
            }
        },
        "outputFormats": {
            "outputFormat": ["HTML"]
        }
    }

More options can be supplied while the creating job.



来源:https://stackoverflow.com/questions/34305093/jasper-report-with-restapi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!