kothany Posted April 12, 2019 Share Posted April 12, 2019 1. I created a server attribute with name 'env_url' and value ="http://......."2. I want to use this in the JSON data adapter.Is it possible to pass a server attribute like below to a JSON data adapter ?<?xml version="1.0" encoding="UTF-8" ?><jsonDataAdapter class="net.sf.jasperreports.data.json.JsonDataAdapterImpl"><name>smc-per-calendar-json-adapter_2</name><dataFile xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="httpDataLocation"><url>$P{ServerAttribute_env_url}+"/users"</url><method>GET</method><header> <name>contentType</name><value>application/json;charset=utf-8</value> </header><header> <name>accept</name><value>application/json;charset=utf-8</value></header><urlParameter>......I get :net.sf.jasperreports.engine.JRRuntimeException: net.sf.jasperreports.engine.JRException: Error opening input stream from URL: repo:/reports/dataadapter/myJsonDataAdapter.xml. at net.sf.jasperreports.repo.DefaultRepositoryService.getInputStream(DefaultRepositoryService.java:116) at net.sf.jasperreports.repo.InputStreamPersistenceService.load(InputStreamPersistenceService.java:45) at net.sf.jasperreports.repo.DefaultRepositoryService.getResource(DefaultRepositoryService.java:149).... The data source url changes per environment (dev, qa, prod), so I would like it dynamically set. I am trying achieve it with server attributes (I may have a jasper server instance running per environment). Any other suggestions are appreciated. Link to comment Share on other sites More sharing options...
narcism Posted April 15, 2019 Share Posted April 15, 2019 Maybe this answer here helps: https://community.jaspersoft.com/questions/1107291/traversing-json-output-rest-api-datasource Link to comment Share on other sites More sharing options...
kothany Posted April 15, 2019 Author Share Posted April 15, 2019 Thank you narcism. Its working, the link you provided has solved my problem. 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