Jump to content
Changes to the Jaspersoft community edition download ×

Recommended Posts

Hi there,
I'm trying to change a report datasource via REST Services, but my HTTP request does not seem to overwrite the report data source which has been deployed on Jasper Server. I guess there is something wrong with my resource descriptor. This is the java code I'm using: 

HttpRequestBase httpReq = new HttpPut();     BasicHttpEntity reqEntity = new BasicHttpEntity();     String requestXml="<resourceDescriptor name='TestUdc1' wsType='reportUnit' " +                       "uriString='/reports/test/TestUdc' isNew='false'>" +                       " <label>Bar Unit</label> " +                       "<description>This is a test</description> " ;                 String requestXml2="<resourceDescriptor name='' wsType='datasource' uriString='/reports/test/TestUdc' isNew='false'>"+                        "<label> Test </label>"+                        "<resourceProperty name='PROP_REFERENCE_URI'>"+                        "<value>/datasources/PilocDS</value>"+                        "</resourceProperty>"+                        "<resourceProperty name='PROP_IS_REFERENCE'>"+                        "<value>true</value>"+                        "</resourceProperty>"+                        "</resourceDescriptor>"+                        "</resourceDescriptor>";                 requestXml=requestXml+requestXml2;     reqEntity.setContent(new ByteArrayInputStream(requestXml.getBytes()));     ((HttpEntityEnclosingRequestBase) httpReq).setEntity(reqEntity);                   URI uri = createURI("/report/reports/test/TestUdc?RUN_OUTPUT_FORMAT=HTML", null, false);                 httpReq.setURI(uri);     httpRes = httpClient.execute(httpReq, httpContext);     System.out.println("Response status line:"+httpRes.getStatusLine());                   String responseReportRD = EntityUtils.toString(httpRes.getEntity());                   DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();     DocumentBuilder builder = domFactory.newDocumentBuilder();     StringReader sr = new StringReader(responseReportRD);     InputSource is = new InputSource(sr);     Document xmlDoc = builder.parse(is);                   //Extracting the report's UUID     NodeList nodes = xmlDoc.getElementsByTagName("uuid");     String reportUuid = nodes.item(0).getTextContent();     System.out.println("-----ReportUUid:"+reportUuid);[/code]

Any suggestion would be appreciated.

Thanks,

Alessandro

Link to comment
Share on other sites

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

Top Posters In This Topic

Sorry for reviving this dead post, but was never answered and the title is perfect.

Is it possible to change the datasource in the rest call? This is what I'm trying:

http://localhost:8080/jasperserver/rest_v2/reports/unik/ReporteDiario.pdf?REPORT_DATA_SOURCE=resource_id[/code]

Replace the resource_id with any REPORT_DATA_SOURCE ID. But it doesn't work.

If it isn't possible, what is the motive? Where I can read about it?

Thank you! Luciano.

Link to comment
Share on other sites

I found a solution! Is not through the REST API but with environment variables! (Even better)

Doc: https://community.jaspersoft.com/documentation/tibco-jasperreports-server-administrator-guide/v601/attributes-data-source-definitions

Short answer: configure one data source with environment variables, and then set those variables on the server, role or user.

Luciano.

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