Dynamic user authentication for json datasource over rest. Works fine on Jaspersoft Studio, but fails on JasperReports Server with an unauthorized error.

0

I have a jasper report that uses a JSON data adapter to retrieve data from a rest api. The username and password for http basic authentication should be set dynamically. Therefore the reports has input parameter for them. In Jaspersoft Studio it works well, but on the JasperReports Server a unauthorized error is thrown even before prompting the user to enter the values for the parameters.

The error message on the server:  2019-10-17 08:54:01,136 ERROR GenericExceptionMapper,http-nio-8080-exec-6:51 - Unexpected error occurs net.sf.jasperreports.engine.JRRuntimeException: Response has status code HTTP/1.1 401 Unauthorized.

I wonder why it works on Studio but not on the Server.

This is how i forward the input parameters to the dataadapter:
<parameter name="USERNAME" class="java.lang.String">
    <property name="net.sf.jasperreports.http.data.username"/>
</parameter>
<parameter name="PASSWORD" class="java.lang.String">
    <property name="net.sf.jasperreports.http.data.password"/>
</parameter>

mexxDev's picture
Joined: Jul 31 2019 - 12:24am
Last seen: 1 month 2 days ago

1 Answer:

0

When you deployed the report to the JasperReports Server, what data source did you use for the Report Unit?

A JasperReports Server data source is not a data adapter.

You could try setting the report to use a data adapter on the server, as per https://community.jaspersoft.com/wiki/how-deploy-and-use-data-adapter-jasperreports-server-v56

swood_1's picture
743
Joined: Nov 15 2012 - 10:47am
Last seen: 3 days 10 hours ago
Feedback