Using Rest v2, setting the report locale can be done by attaching userLocale=tr to the request.
But Rest v2 has an issue when it comes to get the JRPRINT file of the report. Although the documentation mentions that
http://
where
it just not working. So I decied to get JRPRINT file with Rest V1. To achieve this followed the documentation as
1) Login with userLocale=tr attached: POST httpp://domain/jasperserver/rest/login
2) Get the report unit: GET httpp://domain/jasperserver/rest/resource/reports/myReport
3) Add parameters to the reportUnit descriptor.
/* try all combinations */
<parameter name="userLocale">tr</parameter>
<parameter name="reportLocale">tr</parameter>
<parameter name="REPORT_LOCALE>tr</parameter>
... other parameters ...
then run the report: PUT httpp://domain/jasperserver/rest/report/reports/myReport?RUN_OUTPUT_FORMAT=JRPRINT&reportLocale=tr&userLocale=tr&REPORT_LOCALE=tr
(Side note: The docs says the returned status code should be 200 but actually it is 201 if successful)
4) Get the report output using the UUID returned from previous PUT: GET httpp://domain/jasperserver/rest/report/UUID?file=jasperPrint
This works fine. I can get the JRPRINT file. However even though trying to set all possible parameters (userLocale, reportLocale, REPORT_LOCALE) through both by request body and query string, the report language (filled resource bundle) is still not in tr (turkish).
I reasoned this by exporting the JRPRINT file with JRTextExporter as follows:
JRExporter exporter = new JRTextExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRTextExporterParameter.CHARACTER_WIDTH, new Float("5"));
exporter.setParameter(JRTextExporterParameter.CHARACTER_HEIGHT, new Float("13"));
exporter.setParameter(JRTextExporterParameter.PAGE_WIDTH, new Float("200"));
exporter.setParameter(JRExporterParameter.CHARACTER_ENCODING, "UTF-8");
exporter.setParameter(JRTextExporterParameter.PAGE_HEIGHT, new Float("200"));
exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, outputStream);
exporter.exportReport();
I want to able to set the locale of the report running on the server using REST v1 webservices.
Any help is appreciated.
Jasperserver CE 5.0.0 with default configurations.
3 Answers:
Ok after looking into the source code of Jasperserver, I was able to solve the problem. Thanks anyway.
Solution:
http://localhost:8080/jasperserver/rest_v2/reports/path_to_report/myrepo...