Rest v1 web service: Set the report output locale

1

 

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://:/jasperserver[-pro]/rest_v2/reports/path/to/report.?
where is one of the following: html, pdf, xls, rtf, csv, xml, jrprint

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.

 

kairat.biy's picture
Joined: Dec 13 2012 - 3:24am
Last seen: 6 years 5 months ago

3 Answers:

-1

Ok after looking into the source code of Jasperserver, I was able to solve the problem. Thanks anyway.

kairat.biy's picture
Joined: Dec 13 2012 - 3:24am
Last seen: 6 years 5 months ago

Hi, we have a similar issue, how exactly did you solve the problem?

gideon.maree - 5 years 8 months ago
0

i am new user can u explain solution ?

oguz.turkan's picture
Joined: Jan 4 2014 - 3:02pm
Last seen: 5 years 6 months ago
0

I'v got similar problem,

If you use rast v1 and want to set locale just add parameter:

<parameter name="REPORT_LOCALE">pl_PL</parameter>

spam_6's picture
3
Joined: Oct 28 2014 - 5:31am
Last seen: 4 years 8 months ago
Feedback
randomness