title: Generate SSRS report in memory
body: <p>I'm working on solution to generate SSRS report in memory to attach after as mail attachment. I'm using 2010 version.</p>
  
  <p>Report has required parameters that should be filled to render report correct.</p>
  
  <p>I found few solution how to do this:</p>
  
  <p><strong>Solution 1</strong></p>
  
  <p>Using MS native <code>ReportViewer</code> class. We can instantiate object in memory, connect to server and render report in required format using control API</p>
  
  <pre><code>report.ServerReport.ReportServerCredentials = new MyCredentials(...);
  report.ServerReport.ReportServerUrl = new Uri("ssrs_url");
  report.ServerReport.ReportPath = "path-to-report";
  
  byte[] reportData = report.ServerReport.Render("excel");
  </code></pre>
  
  <p>The solution have main drawback - it requires significant set of dependencies to use reporting control. So it hard to use in layered architecture, when lower layers have limited and predefined set of dependencies to be loose coupled and be easy ported to wide range OS'es and cloud stacks.</p>
  
  <p>So can't adopt this solution in my case</p>
  
  <p><strong>Solution 2</strong></p>
  
  <p>Use report server public API to access data already in required format. I found out that this can be achieved and MS confirms this. Here is link <a href="https://msdn.microsoft.com/en-us/library/ms154040.aspx" rel="nofollow noreferrer">https://msdn.microsoft.com/en-us/library/ms154040.aspx</a></p>
  
  <p>So we can just use right configured link to access data: <a href="http://myrshost/ReportServer?/myreport&amp;rs:Format=PDF" rel="nofollow noreferrer">http://myrshost/ReportServer?/myreport&amp;rs:Format=PDF</a></p>
  
  <p>This solution best suited for my needs, but I don't know how to pass report parameters to this report? Also how to authenticate first against SSRS report server?</p>
  
  <p>Can someone help me with this?</p>