min_3 Posted June 6, 2019 Share Posted June 6, 2019 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. https://community.jaspersoft.com/questions/1111291/web-service-using-json-data-adapter-passing-http-parameters-url-body-through Link to comment Share on other sites More sharing options...
Tirupathi Mangalarapu Posted October 25, 2021 Share Posted October 25, 2021 Hello There,Did you explore Auto REST Driver? Here is KBA: https://community.jaspersoft.com/wiki/autonomous-rest-connector-tibco-jaspersoft-studioAuto 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. https://docs.progress.com/bundle/datadirect-autonomous-rest-connector-jdbc-60/page/Creating-an-input-REST-file.htmlHope 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now