Jump to content
We've recently updated our Privacy Statement, available here ×

marascoalessandro

Members
  • Posts

    1
  • Joined

  • Last visited

marascoalessandro's Achievements

Newbie

Newbie (1/14)

  • Week One Done
  • One Month Later
  • One Year In
  • First Post Rare
  • Conversation Starter Rare

Recent Badges

0

Reputation

  1. 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
×
×
  • Create New...