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>...
// 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
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
Thanks hozawa. It is working with pdf.
Is there a way to make it work with html also.