Jump to content
We've recently updated our Privacy Statement, available here ×

ivan.krsul

Members
  • Posts

    1
  • Joined

  • Last visited

ivan.krsul's Achievements

Newbie

Newbie (1/14)

  • Week One Done
  • One Month Later
  • One Year In
  • First Post Rare
  • Conversation Starter Rare

Recent Badges

0

Reputation

  1. I am trying to extract from the jasperserver a report, using Web Services 5.0, a report in PDF format, but I am am getting a blank PDF file. I am coding in C#/ASP.NET and I managed to get the query to work for all formats except for PDF as follows: // Setup WebClient WebClient httpclient = new WebClient(); //Basic Auth httpclient.Credentials = new NetworkCredential("jasperadmin", "jasperadmin"); httpclient.Headers.Add("Content-Type", "application/x-www-form-urlencoded"); // Build resourceDescriptor string requestXml = System.IO.File.ReadAllText(Server.MapPath("XMLFile.xml")); // Send PUT string requestAllResult = ""; requestAllResult = httpclient.UploadString("http://localhost:8080/jasperserver/rest/report/reports/IvanReports/TestReport2?RUN_OUTPUT_FORMAT=PDF", "PUT", requestXml); // Get session cookie string session = httpclient.ResponseHeaders.Get("Set-Cookie"); // Set session cookie httpclient.Headers.Add("Cookie", session); // Extract uuid, filename is always report 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://localhost:8080/jasperserver/rest/report/"; reportUrl += uuid; reportUrl += "?file=report"; // Get report string report = httpclient.DownloadString(reportUrl); // Send the report to the user // I AM ASSUMING THE BUG IS HERE... but I may be mistaken Response.ContentType = "application/pdf"; Response.AddHeader("Content-Disposition", "attachment; filename=file.pdf"); Response.ClearContent(); byte[] bytes = System.Text.UTF8Encoding.UTF8.GetBytes(report); Response.OutputStream.Write(bytes, 0, bytes.Length); Response.Flush(); Response.Close();[/code] The XML I am using is as folows: <resourcedescriptor isnew="false" name="TestReport2" uristring="/reports/IvanReports/TestReport2" wstype="reportUnit"> </resourcedescriptor> The report I am trying to extract works well in jasperserver using the Web interface, and I can generate the PDF report there without any trouble. Does anyone know why this code is getting a blank PDF for the report? Ivan
×
×
  • Create New...