Jasper异步报告 - 空,为什么?

时间:2015-10-22 12:57:16

标签: javascript angularjs jasper-reports jasperserver

让我们开始,首先我得到exmaple特定报告的参数

var config = {
    url : "http://exmaple.com/jasperserver/rest_v2/reports/reportFolder/exampleReport/inputControls",
    method: "GET",
    headers: {
        Accept: "application/json;"
    },
}

一切都很好,我得到了一系列输入的回复,

数组包含2个对象:

首先:

{
description: "Date_from",
id: "Date_from",
label: "Date from",
type: "singleValueDate"
}

第二

{
description: "Date_to",
id: "Date_to",
label: "Date_to",
type: "singleValueDate"
}

两个输入都有一个属性:

validationRules[0].dateTimeFormatValidationRule.format = "yyyy-MM-dd"

所以现在我想运行异步报告(我现在将传递异步参数false,这里代码较少)

var params ={
    reportUnitUri: "/reportFolder/exampleReport",
    outputFormat: "html",
    freshData : true,
    saveDataSnapshot : false,
    ignorePagination: true,
    async : false,
    interactive: false,
    allowInlineScripts: true,
    parameters: {
        "Date_from":["2014-08-01"],
        "Date_to":["2015-10-08"]
    }
}

所以现在我尝试生成异步报告:

var config = {
        url : "http://exmaple.com/jasperserver/rest_v2/reportExecutions",
        headers: {
            Accept: "application/json"
        },
        data: params,
        method: "POST"
    }

我得到了成功回复,但是

totalPages: 0,
requestId: "0200cf28-300f-4e76-b99e-e479be4980ba",
reportURI: "/reportFolder/exampleReport/",
status: "ready",
exports[0].id: "c9a5578a-6bc8-4c3e-8a78-9056ef19f456",
exports[0].status: "ready",
exports[0].outputResource :{
    contentType: "text/html",
    outputFinal: true
}

当我尝试通过调用

来获取报告的输出时
 http://exmaple.com/jasperserver/rest_v2/reportExecutions/0200cf28-300f-4e76-b99e-e479be4980ba/exports/c9a5578a-6bc8-4c3e-8a78-9056ef19f456/outputResource

报告是空的。

运行相同的通道:

http://exmaple.com/jasperserver/rest_v2/reports/reportFolder/exampleReport.html?Date_from=2014-08-01&Date_to=2015-09-08

给我一​​份填好的报告,

有谁能指出我做错了什么? :/ 我非常确定这些参数可能有问题,但我尝试了各种各样的方式而且我无法自己找到解决方案:/

1 个答案:

答案 0 :(得分:0)

问题是传递给异步报告的参数格式错误,应该是这样的:

parameters: {
    reportParameter: [
        {name : "Date_from",value : ["2014-08-01"]},
        {name : "Date_to",value : ["2015-10-08"]}
    ]
}