Jump to content
Changes to the Jaspersoft community edition download ×

Passing a Collection to Jasper Server via REST_v2 api


florian.johannssen

Recommended Posts

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?MyCountries=USA&MyCountries=Mexico

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

Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

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/Reports/RevenueDetailReport.html?ProductFamily=Drink&ProductFamily=Food

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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[/code]

 

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

Link to comment
Share on other sites

  • 4 years later...

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_No_10.pdf?cId=1;12496;1;7819&cId=1;23373;1;18536&username=myUsername&passwd=mypassword

 

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,

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...