Passing a Collection to Jasper Server via REST_v2 api

Hi folks,

I have a report with a parameter as type of a java.util.collection. I am using this parameter in the SQL of my Jasper-Studio as: AND $X{IN,country,MyCountries}

I am not able to pass the value into the MyCountries parameter via the restv2 api in the URL.

I try to call the report like: 

GET http://HOST:8080/jasperserver/rest_v2/reports/Reports/MyReport.pdf?MyCou...

The problem is, that the parameter USA and Mexico will be ignored. Has anyone a suggestion? This would be very very helpful.

 

Best regards

Florian

florian.johannssen's picture
Joined: Sep 25 2014 - 8:25am
Last seen: 6 years 2 weeks ago

2 Answers:

If the report parameter is a collection using multiple values, you can specify them using the ampersand (&), such as

country=US&country=Canada

ProductFamily=Drink&ProductFamily=Food

For example (using our sample Revenue Detail Report tested in JRS 6.0.1):

http://localhost:8080/jasperserver-pro/rest_v2/reports/public/Samples/Re...

tchen's picture
123030
Joined: Feb 27 2008 - 7:33am
Last seen: 10 hours 24 min ago

Thank you very much for your answer. If I follow our suggestion, the parameter ProductFamiliy is empty by running the report (An empty list will be printed). The type of the parameter is java.util.collection.
It seems to be that the input data of the client like Drink and Food will not pass to the Jasper Studio Collection Parameter :(
Do you know what I am doing wrong?

Best Regards

Florian

florian.johannssen - 8 years 6 months ago

Hello,

I have a report to print some envelopes and its only parameter is a collection of strings that are a concatenation of four numeric values separated by semicolon (and tried with underscores also) in order to print the correct combination of ids, that is why four simple integer parameters does not work even using the IN operator. I did what you describe here and it is in the documentation, so my URL to generate the report is similar to this:

http://jasperserver:8050/jasperserver/rest_v2/reports/Reports/Envelope_N...

I have to note that when I sent the GET request without the parameters (except the username and password) the report is shown as a blank envelope, which is correct. However, if I set the parameter no matter if it is only one or many I get a 400 error. As I said I tried separating the numbers with underscores and semicolons with no avail. I tested in Jasper Reports application and the parameter must be defined as ['1;12496;1;7819','1;23373;1;18536'] in order to work as expected.

How do I achieve that, What I am doing wrong? is it a bug? because the usage is the same as the documentation states.

Best Regards,

ficticia - 4 years 1 month ago

If you have sample report deployed in JRS repository, you should have "Revenue Detail Report" under public samples reports folder. This report has a collection type parameter named "ProductFamily". The following URL will provide the selected collection values "Drink" and "Food" to the report unit through a REST V2 report execution.

http://localhost:8080/jasperserver-pro/rest_v2/reports/public/Samples/Reports/RevenueDetailReport.html?ProductFamily=Drink&ProductFamily=Food

The above URL is used to test in a JRS 6.0.1 instance and it should work. Are you using the exact syntax when run your test? Which version of JRS are you using?

Notice the following part in the URL is REPORT SPECIFIC:

/public/Samples/Reports/RevenueDetailReport.html?ProductFamily=Drink&ProductFamily=Food

If you have your report unit named MyReport deployed under /public/project/reports folder, and your report has a collection parm named InputList, then the URL for your report and parms should be

/public/project/reports/MyReport.html?InputList=Text1&InputList=Text2

tchen's picture
123030
Joined: Feb 27 2008 - 7:33am
Last seen: 10 hours 24 min ago
Feedback