Search code examples
javascriptangularjsjasper-reportsjasperserver

Jasper Async Report - Empty, why?


Lets start , firstly I get parameters for specific report for exmaple

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

Everything is ok, I get a response with an array of inputs,

The array contains, 2 objects with :

First:

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

Second:

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

Both inputs have a property:

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

So now I want to run a async report (I will pass async parameter false for now, se there is less code here)

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

So now I try to generate async report:

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

I get a success response, but

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
}

When I try to get the output of the report by calling :

 http://exmaple.com/jasperserver/rest_v2/reportExecutions/0200cf28-300f-4e76-b99e-e479be4980ba/exports/c9a5578a-6bc8-4c3e-8a78-9056ef19f456/outputResource

The report is empty.

Runing the same via :

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

Gives me a filled report,

Can anyone point me what I'm doing wrong ? :/ I'm pretty sure that it may be something wrong with the parameters but I tried in various ways and I can't find a solution by myself :/


Solution

  • The thing was that the parameters passed to the async report were badly formatted, it should be like this:

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