Chart not displaying in report

1

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/StandardC...", "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

admin.vizexperts's picture
Joined: Feb 25 2014 - 2:53am
Last seen: 5 years 3 months ago

2 Answers:

0

Instead of html, try retrieving report in pdf format.

hozawa's picture
45149
Joined: Apr 24 2010 - 4:31pm
Last seen: 1 month 1 week ago

Thanks hozawa. It is working with pdf.
Is there a way to make it work with html also.

admin.vizexperts - 5 years 4 months ago
0

Yes. You can put your images in /themes/default/images/ folder and use

("http://localhost:8080/jasperserver/themes/default/images/image file name.png

That said, if you put your images files within report resource folder, you really shouldn't be having this problem. Check "To Publish a report to the server" pp.61-62 in the "Jaspersoft Studio User Guide".

hozawa's picture
45149
Joined: Apr 24 2010 - 4:31pm
Last seen: 1 month 1 week ago

how can we save our charts in the said location, because html generates at run time. It generates on call of rest API. Please help. I am using the asp.net to call rest api of jasperreport server

admin.vizexperts - 5 years 4 months ago

I really need this feature. I know it can be done, but don't know how.
Please help
Thanks

admin.vizexperts - 5 years 4 months ago
Feedback
randomness