title: WebRequest for SSRS report- gives 500 Internal Server Error
body: <p>Trying to execute an SSRS report via a WebRequest object. The call to get the response gives a "500 Internal Server Error" with no more information (I check parameter values etc are valid in the browser) </p>
  
  <p>I debugged to grab the url, and pasted it into the browser and it worked successfully.</p>
  
  <pre><code>http://devBI/ReportServer?%2fSSRS+Project%2fValuationReport&amp;rs:Command=Render&amp;rs:Format=EXCEL&amp;ReportDate=23/06/2013&amp;ClientCode=QWECT&amp;IsEOM=0
  </code></pre>
  
  <p>The code in question is:</p>
  
  <pre><code>WebRequest Request = HttpWebRequest.Create(reportUrl);
  Request.Credentials = CredentialCache.DefaultCredentials;
  log.Debug("Credentials for request: " + Request.Credentials.ToString());
  if (config.UseInfiniteTimeout)
  {
      Request.Timeout = System.Threading.Timeout.Infinite;
  }
  else
  {
      Request.Timeout = config.TimeoutSeconds * 1000;
  }
  
  Request.Method = "GET";
  try
  {
      HttpWebResponse Response = (HttpWebResponse)Request.GetResponse();
      using (Stream ResponseStream = Response.GetResponseStream())
      {
          string responseString;
          StreamHelper.CopyStream(Response.GetResponseStream(), out responseString);
          ResponseStream.Flush();
          ResponseStream.Close();
  
          log.Debug("Response string: " + responseString);
          return responseString;
      }
  }
  catch (Exception e)
  {
      log.Error("Error encountered during WebRequest/Response: " + e.ToString());
      throw;
  }
  </code></pre>