I am attempting to automate the download of files from a secured web site. I have been able to automate the upload process but I am being plagued by errors when I attempt to automate the download process. Here are the details . . .
C#; Using HttpWebRequest
I am able to successfully log on to the web site; I am able to successfully get a response back with a directory listing of the files that are available for download.
I have formatted my query string exactly as it appears on the web source when viewed through a browser. However, when I try to perform the download action via my C# application, I receive the following error . . . (I'll post as many pieces that I think might help debug this . . .)
- System.InvalidOperationException {System.Net.WebException} System.InvalidOperationException
+ System.SystemException {"The remote server returned an error: (500) Internal Server Error."} System.SystemException
StackTrace " at System.Net.HttpWebRequest.CheckFinalStatus()\r\n at System.Net.HttpWebRequest.EndGetResponse"
Here's what my code looks like . . .
I have this surrounded by a try/catch block and the exception is being thrown when I attempt to do any sort of read on the response stream.
Any ideas, suggestions, comments, or debug hints would be most appreciated!
Thanks in advance!
Stay Cool Ya'll!![[smile2] [smile2] [smile2]](/data/assets/smilies/smile2.gif)
-- Kristin
C#; Using HttpWebRequest
I am able to successfully log on to the web site; I am able to successfully get a response back with a directory listing of the files that are available for download.
I have formatted my query string exactly as it appears on the web source when viewed through a browser. However, when I try to perform the download action via my C# application, I receive the following error . . . (I'll post as many pieces that I think might help debug this . . .)
- System.InvalidOperationException {System.Net.WebException} System.InvalidOperationException
+ System.SystemException {"The remote server returned an error: (500) Internal Server Error."} System.SystemException
StackTrace " at System.Net.HttpWebRequest.CheckFinalStatus()\r\n at System.Net.HttpWebRequest.EndGetResponse"
Here's what my code looks like . . .
Code:
postdata = postdata.Substring(0,postdata.Length-1);
data.Initialize();
data = Encoding.ASCII.GetBytes(postdata);
string DowloadURL = ServletURL + postdata;
webRequest = (HttpWebRequest) WebRequest.Create(DowloadURL);
webRequest.CookieContainer = cookies;
webRequest.Method = "POST";
webRequest.ContentType="application/x-[URL unfurl="true"]www-form-urlencoded";[/URL]
webRequest.ContentLength = data.Length;
requestWriter = webRequest.GetRequestStream();
if (requestWriter.CanWrite)
{
requestWriter.Write(data, 0, data.Length);
requestWriter.Close();
}
responce = (HttpWebResponse) webRequest.GetResponse();
s = responce.GetResponseStream();
sr = new StreamReader(s);
stext = sr.ReadToEnd();
I have this surrounded by a try/catch block and the exception is being thrown when I attempt to do any sort of read on the response stream.
Any ideas, suggestions, comments, or debug hints would be most appreciated!
Thanks in advance!
Stay Cool Ya'll!
![[smile2] [smile2] [smile2]](/data/assets/smilies/smile2.gif)
-- Kristin