Good Day All
i have a Reporting Service URL that i dynamically pass the Parameters on a Querystrng and if i take that URL and post it on a BRowser it downloads the PDF file. so i want to do this in C# , this code runs in a WCF service
public void GetAccountEmailStatement(string AccountNumber, string EmailAddress)
{
try
{
//
string remoteUri = "http://myserver/ReportServer/Pages/ReportViewer.aspx?%2fE-Billing%2fISU_PDF_GEN_1&rs:Command=Render&Contract_Account_Number=" + AccountNumber + "&Post_Date=26/02/15&rs:Format=PDF";
string fileName = HttpContext.Current.Server.MapPath("/Temp/" + AccountNumber + ".pdf");
WebClient webClient = new WebClient();
webClient.DownloadFile(remoteUri, fileName); //Error hapeens on this line
}
catch (SqlException ex)
{
throw ex;
}
finally
{
this.con.Close();
}
}
The Error i get when its supposed to download the file is
[COLOR="#FF0000"]The remote server returned an error: (401) Unauthorized.[/COLOR] Please help
Thank you for posting at Dotnetfunda
[Administrator]