1
votes

I am using JasperReports Server Web Services to retrieve a report as PDF using php curl.

Unfortunately, the report I want to generate uses a value as Input Control

If I don't provide a value to this input control, my report works but every value is 0.

According to the official guide : JasperReports Server Web Services Guide page 24, it says I should use the IC_GET_QUERY_DATA argument in the URL so I did it and provided the URI of the data source and then I used P_param_name to provide the value of the parameter but I can't get it to work, it seems the report is not using these values.

Thank you in advance for any comment that may help !

1

1 Answers

0
votes

You may consider using the new run report mechanism (part of the "RESTv2 services"). You can supply input controls for your report as query items in the URL. Multi-select inputs can be defined as many times as you need selections made.

For example, if you send a GET request to http://[yourserver]:[port]/jasperserver/rest_v2/reports/uri/to/my_report.pdf?state=CA&state=OK&city=Sacramento

You will get a report where the State control is set to "OK" and "CA", and the City control is set to "Sacramento"

It may be beneficial for you to use the REST php wrapper to make these requests more simple.

The same example as above can be achieved like this:

$client = new JasperClient('yourserver', 'port', 'username', 'password', '/jasperserver');
$report_data = $client->runReport('/uri/to/my_report', 'pdf', null, null, array('state' => array('OK', 'CA'), 'city' => 'Sacramento'));

The binary data of the report will be stored in $report_data and you can do with it whatever you wish. (i.e: fwrite to file, stream to browser for download... etc).