I use the following Rest Call to download a report:
http:/localhost:8080/jasperserver/rest_v2/reports/reports/example.pdf?PRINTED_BY=ME
Is it possible to add the name of the datasource as a parameter so I can select between different databases and only have 1 report for both?
I thought something like that:
http:/localhost:8080/jasperserver/rest_v2/reports/reports/example.pdf?PRINTED_BY=ME&DATASOURCE=DEV
http:/localhost:8080/jasperserver/rest_v2/reports/reports/example.pdf?PRINTED_BY=ME&DATASOURCE=PROD
But I am not sure how to implement that within the report.
http:/localhost:8080/jasperserver/rest_v2/reports/reports/example.pdf?PRINTED_BY=ME&DATASOURCE=DEV
1 Answer:
Ok, so apparantly this does not work with REST, but there is a workaround in the new versions of Jasper Server (I am using 6.3) as described here.
So I created a new datasource with user attributes
Host (required)
{attribute('host','User')}
etc.
I created 2 users, one for production and one for development.
For both users I created an attribute called "host" and the value of the host attribute is the server url for your database.
You can then do the same for port, databasename, username and password.
You can then test the connection to your database by logging in with each user account and hit "test connection" and if everything was entered correctly, the connection can be established.