Jump to content

admin.vizexperts
Go to solution Solved by hozawa,

Recommended Posts

Hello everyone,

I am browsing the jasperserver sample report from my web application.  There it is showing the report, but not displaying the charts.

For chart it is showing the blank image.

In browser console it is showing 404 error.  

It is taking reference from my webapp url like: http://localhost:4710/<Websitename>/Reports/images/img_0_6_0    and showing this 404 error

It is because the file is not there and it is true.

While i am browsing same report from jasperserver gui it is showing the report with charts.

I am using the rest api.

My code is:

string fileName = "StandardChartsAegeanReport.html";
        var responseValue = string.Empty;
 
        WebClient httpClient = new WebClient();
        httpClient.Credentials = new NetworkCredential("jasperadmin", "jasperadmin");
        httpClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
 
        // Build resourceDescriptor
 
        string requestXml = "";
        requestXml = "<resourceDescriptor name="StandardChartsAegeanReport" wsType="reportUnit" uriString="/reports/samples/StandardChartsAegeanReport"";
        requestXml += " isNew="false">";
        requestXml += "<dataSourceReference><uri>/datasources/JServerJNDIDS</uri></dataSourceReference>";
        requestXml += "<resources>";
        requestXml += "<resource>";
        requestXml += "<fileReference>";
        requestXml += "<uri>/reports/samples/StandardChartsAegeanReport_files/standardCharts.properties</uri>";
        requestXml += "</fileReference>";
        requestXml += "<name>standardCharts.properties</name>";
        requestXml += "</resource>";
        requestXml += "<resource>";
        requestXml += "<fileReference>";
        requestXml += "<uri>/reports/samples/StandardChartsAegeanReport_files/standardCharts_ro.properties</uri>";
        requestXml += "</fileReference>";
        requestXml += "<name>standardCharts_ro.properties</name>";
        requestXml += "</resource>";
        requestXml += "</resources>";
 
 
        requestXml += "<jrxmlFileReference><uri>/reports/samples/StandardChartsAegeanReport_files/StandardChartsAegeanReport</uri></jrxmlFileReference>";
        requestXml += "</resourceDescriptor>";
 
        // Send PUT, the requestAllResult contains the above <report>...
 
        string requestAllResult = httpClient.UploadString("http://localhost:8080/jasperserver/rest/report/reports/samples/StandardChartsAegeanReport?RUN_OUTPUT_FORMAT=HTML", "PUT", requestXml);
 
        // Extract uuid and file
        System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
        doc.LoadXml(requestAllResult);
        XmlNode node = doc.DocumentElement.SelectSingleNode("uuid");
        string uuid = node.InnerText;
 
        //Build GET URL  1ac3fabf-5d55-4e3c-b517-0ef538b7da27
        string reportUrl = "http://localhost:8080/jasperserver/rest/report/";
        reportUrl += uuid;
        reportUrl += "?file=report";
 
        // Get session cookie
        string session = httpClient.ResponseHeaders.Get("Set-Cookie");
        // Set session cookie
        httpClient.Headers.Add("Cookie", session);
 
        var reportdata = httpClient.DownloadData(reportUrl);
        string folder = Server.MapPath(Request.ApplicationPath + @"Reports" + fileName);
        System.IO.File.WriteAllBytes(folder, reportdata);
 
        Response.Redirect("Reports/" + fileName);

Please suggest me how to retrieve charts from jasperreport using rest api.

thanks

Link to comment
Share on other sites

  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

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