Passing a Collection to Jasper Server via REST_v2 api

0

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: 1 year 10 months ago

2 Answers:

0

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
41275
Joined: Feb 27 2008 - 7:33am
Last seen: 16 hours 15 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 - 4 years 4 months ago
0

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
41275
Joined: Feb 27 2008 - 7:33am
Last seen: 16 hours 15 min ago
Feedback
randomness