-
Apr 16th, 2015, 03:37 AM
#1
Thread Starter
Fanatic Member
Downloading a PDF File from a URL
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
Code:
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
The remote server returned an error: (401) Unauthorized.
Please help
-
Apr 17th, 2015, 04:21 PM
#2
Re: Downloading a PDF File from a URL
sounds like you need credentials to download that file
-
Apr 18th, 2015, 02:10 PM
#3
Thread Starter
Fanatic Member
Re: Downloading a PDF File from a URL
Thanks for the Reply, i have access to the reporting server. what should i do to make this work in terms of credentials, do i add a user for this service in Reporting Service and make a change on the Service to accommodate that user ?
-
Apr 18th, 2015, 05:44 PM
#4
Re: Downloading a PDF File from a URL
odds are there is more than whats in the querystring being passed that is the problem. I'm guessing that there's a cookie or something that needs to be set as part of the request. Try using Fiddler to see what is bei ng passed between tbhe client and reporting services... you may need to mimmic more than the qs.
-tg
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|