title: Get report from jasperserver using REST webservice and asp.net C#
body: <p>You can use the jasperservers webservices (SOAP and REST is available) to get mange and run reports on from a web application. The SOAP wsdl is not compatible with asp.net c# (at least, I cannot get it to work), so I decided to use the REST webservice.</p>
  
  <p>I am ALMOST there, but I can't retrieve the report itself. does anyone know what goes wrong?
  I am using jasperserver CE 4.5 on Linux.</p>
  
  <pre><code>// Setup WebClient 
  WebClient httpclient = new WebClient();
  
  //Basic Auth
  httpclient.Credentials = new NetworkCredential("NAME", "PASSWD");
  httpclient.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
  
  // Build resourceDescriptor
  string requestXml;
  requestXml =  "&lt;resourceDescriptor name="budget_overzicht_per_klant" wsType="reportUnit" uriString="/Declaraties/12change/Klant/budget_overzicht_per_klant"n";
  requestXml += " isNew="false"&gt;n";
  requestXml += "   &lt;label&gt;null&lt;/label&gt;n";
  requestXml += "   &lt;parameter name="klantid"&gt;14&lt;/parameter&gt;n";
  requestXml += "   &lt;parameter name="start"&gt;20120101&lt;/parameter&gt;n";
  requestXml += "   &lt;parameter name="eind"&gt;20120302'&lt;/parameter&gt;n";
  requestXml += "   &lt;parameter name="Titel"&gt;Test 123&lt;/parameter&gt;n";
  requestXml += "&lt;/resourceDescriptor&gt;n";
  
  // Send PUT
  string requestAllResult = httpclient.UploadString("http://website/jasperserver/rest/report/Declaraties/12change/Klant/budget_overzicht_per_klant?RUN_OUTPUT_FORMAT=PDF", "PUT", requestXml);
  
  // requestAllResult contains:
  //&lt;report&gt;
  //  &lt;uuid&gt;f521fe7d-7432-4c47-962c-9fec29bdaa43&lt;/uuid&gt;
  //  &lt;originalUri&gt;/Declaraties/12change/Klant/budget_overzicht_per_klant&lt;/originalUri&gt;
  //  &lt;totalPages&gt;4&lt;/totalPages&gt;
  //  &lt;startPage&gt;1&lt;/startPage&gt;
  //  &lt;endPage&gt;4&lt;/endPage&gt;
  //  &lt;file type="application/pdf"&gt;&lt;![CDATA[report]]&gt;&lt;/file&gt;
  //&lt;/report&gt;
  // You have to use the uuid to GET the file 'report'
  //
  // Extract uuid, filename is always report
  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://website/jasperserver/rest/report/";
  reportUrl += uuid;
  reportUrl += "?file=report";
  
  // the value of report Url is now 
  // "http://website/jasperserver/rest/report/f521fe7d-7432-4c47-962c-9fec29bdaa43?file=report"
  
  // Get report
  string report;
  report = httpclient.DownloadString(reportUrl);
  
  // Exception, HTTP 404 ERROR????
  </code></pre>
  
  <p>The error seems to mean that the uuid is not in the current session. Anyone got this working? Thanks!</p>