Jump to content

Rest v1 web service: Set the report output locale

Go to solution Solved by kairat.biy,

Recommended Posts


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

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);

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.


Link to comment
Share on other sites

  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

  • 8 months later...
  • 2 months later...
  • 9 months later...
  • 10 months later...

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...