Jump to content
Changes to the Jaspersoft community edition download ×

JSON Data Adapter - error before input parameters prompt


Recommended Posts

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">        <defaultValueExpression><![CDATA["1"]]></defaultValueExpression></parameter>

<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></parameter>

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.  


Link to comment
Share on other sites

  • 2 years later...
  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Hello There,

Did you explore Auto REST Driver?  Here is KBA: https://community.jaspersoft.com/wiki/autonomous-rest-connector-tibco-jaspersoft-studio

Auto REST says you can pass dynamically the params in the rest config. Please refer to this documentation and check if you can accomplish this using AutoREST Driver. 


Hope that helps! Please keep us posted on your findings so that other users can benefit from the outcome.

Link to comment
Share on other sites

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