带有 Rest API 的 Jasper 报告

我有一份关于 JasperServer(5.6) 的报告,它接受的参数很少。我在“输出选项”选项卡上编辑了一些设置,并在“通知”选项卡上输入了我想发送到的电子邮件。报告成功生成,并完美发送了一封电子邮件。

我希望使用 JasperServer 的 Rest API 来传递我的输入选项并安排和通过电子邮件发送报告。我浏览了那里的文档 http://community.jaspersoft.com/documentation/jasperreports-server-web-services-guide/v56/rest-v2-report-services 但不明白如何使用其余的 api。

这是我在 jasper 服务器上的报告的属性

enter image description here

有人可以帮助我如何安排我的报告。

stack overflow Jasper Report with RestAPI
原文答案

答案:

作者头像

也许它可以帮助你: jasperserver rest java client 。这是 Jasperserver 的 REST 客户端。

作者头像

我想,我已经找到了在 jasper 服务器上安排工作的方法。详细信息可以在这里找到

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

但作为一个例子,它是(用 PUT 方法调用它) http://localhost:8080/jasperserver/rest_v2/jobs 并在正文中定义作业结构


     {
        "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"]
        }
    }

创建作业时可以提供更多选项。