JSON Data Adapter - error before input parameters prompt


I have a jasper report that uses a JSON data adapter to retrieve data from a rest api.  The url is being set dynamically in the report using parameters and the user is prompted to supply a value for paramId:

<parameter name="paramId" class="java.lang.String" evaluationTime="Early">
<parameter name="url" class="java.lang.String" isForPrompting="false" evaluationTime="Early">
    <property name="net.sf.jasperreports.http.data.url"/>     
<defaultValueExpression><![CDATA["http://aServiceEndpointUrl/" + $P{paramId}]]></defaultValueExpression>

This all works well if the paramId supplied in the default value expression results in a valid json response from the endpoint call. However they way our endpoints are written, if the supplied paramId does not find any data it returns a 404 response. In this case I get a "There was an error on the server. Try again or contact site administrators. (Error UID: 5d62fb9a-204c-447e-8634-6f703699926d)" error on the report even before the input parameters screen is displayed and I don't even get a chance to supply a valid value for paramId. This creates a dependency on data supplied in the default value expression always being valid. Is the solution to ensure that the endpoint returns an empty string rather than a 404 error or is there a better way to implement this?

I notice that based on the following thread the data adapter gets run twice.


min_3's picture
Joined: Oct 2 2018 - 11:19pm
Last seen: 4 months 6 days ago

0 Answers:

No answers yet