admin.vizexperts Posted March 14, 2014 Share Posted March 14, 2014 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 errorIt 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 More sharing options...
Solution hozawa Posted March 15, 2014 Solution Share Posted March 15, 2014 Instead of html, try retrieving report in pdf format. Link to comment Share on other sites More sharing options...
admin.vizexperts Posted March 15, 2014 Author Share Posted March 15, 2014 Thanks hozawa. It is working with pdf. Is there a way to make it work with html also. Link to comment Share on other sites More sharing options...
hozawa Posted March 16, 2014 Share Posted March 16, 2014 Yes. You can put your images in /themes/default/images/ folder and use("http://localhost:8080/jasperserver/themes/default/images/image file name.pngThat 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". Link to comment Share on other sites More sharing options...
admin.vizexperts Posted March 20, 2014 Author Share Posted March 20, 2014 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 Link to comment Share on other sites More sharing options...
admin.vizexperts Posted March 24, 2014 Author Share Posted March 24, 2014 I really need this feature. I know it can be done, but don't know how. Please help Thanks Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now