Reputation: 57
I have been trying for days to get jasper reports integrated with my .net website. I have tried several ways including the soap and rest service as well as a custom library suggested in another post(http://freeze.ro/?q=node/7). I know I am close but I am fairly new to this and am still trying to understand how it all works. Most people suggest using the rest method and I found a good example on here but I am still getting an error Bad Request. This is my code for the rest request.
WebClient httpClient = new WebClient();
httpClient.Credentials = new NetworkCredential("username", "password");
httpClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
// Build resourceDescriptor
string requestXml;
requestXml = "<resourceDescriptor name=\"Invoice\" wsType=\"reportUnit\" uriString=\"/reports/Nosreports/Invoice\"";
requestXml += " isNew=\"false\">";
requestXml += " <parameter name=\"invoiceid\">1016242</parameter>n";
requestXml += "</resourceDescriptor>";
// Send PUT, the requestAllResult contains the above <report>...
string requestAllResult = httpClient.UploadString("http://SRV9:8080/jasperserver/rest/report/reports/NOSreports/Invoice?RUN_OUTPUT_FORMAT=PDF", "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
string reportUrl = "http://SRV9:8080/jasperserver/rest/resources/report/";
reportUrl += uuid;
reportUrl += "?file=report";
// Get report
string report;
report = httpClient.DownloadString(reportUrl);
Any help is greatly appreciated I have read and read and am ready to give up, I just hate to try and switch to a new reporting service at this point in my project.
Upvotes: 0
Views: 10885
Reputation: 29
I success calling Jasper report via rest v2. Please see my script as attached URL. Hope it is helpful for you.
Asp.net MVC call Jasper report via REST v2 service
Upvotes: 0
Reputation: 57
Thank you Ovan that definitely would have helped me. Unfortunately we have switched to Crystal Reports so I no longer need this.
If anyone has this problem check this link posted by Ovan.
Get report from jasperserver using REST webservice and asp.net C#
Upvotes: 0