使用RestAPI的Jasper报告 [英] Jasper Report with RestAPI

查看:183
本文介绍了使用RestAPI的Jasper报告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



我希望使用JasperServer的Rest API来传递我的输入选项,并安排和通过电子邮件发送报告。我浏览了文档



有人可以帮我解决如何安排报告。

解决方案

我想,我已经想出了在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,
触发器:{
simpleTrigger:{
id:1770,
misfireInstruction:0,
startDate:201 5-12-20T00:00:00 + 11:00,
startType:2,
timezone:澳大利亚/维多利亚,
版本: 0,
occurrenceCount:1
}
},
来源:{
reportUnitURI:/ Reports / Prod / test_automated_report_v14 ,
参数:{
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:发布者月报,
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,
收件人:OWNER_AND_ADMIN,
toAddresses: {
address:[address1@add.com,address2 @add.com]
},
jobState:FAIL_ONLY,
messageText :成功,
messageTextWhenJobFails:失败,
主题:通知主题,
包括StickTrace:true,
includingReportJobInfo:true,
jobState:ALL
},
outputTimeZone:澳大利亚/ Melbourne,
repositoryDe​​stination:{
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]
}
}

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


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.

解决方案

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.

这篇关于使用RestAPI的Jasper报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆