I have to download a file from a website. I got the authentication part done. For the file download I do not have a link to a file like http://whatever.com/file.xlsx
i have a url like this:
http://whatever.com?b_action=cognosViewer&ui.action=view&ui.object=defaultOutput(CAMID(%22eBO%3au%3a11842%22)%2ffolder%5b%40name%3d%27My%20Folders%27%5d%2freport%5b%40name%3d%27AppointmentFacility%27%5d)&ui.name=AppointmentFacility&ui.format=spreadsheetML
this is the code i am using to downoald the file
public void downloadFile(string url, string fileName)
{
// Create a request using a URL that can receive a post.
request = (HttpWebRequest)HttpWebRequest.Create(url);
request.CookieContainer = cookieContainer;
// Set the Method property of the request to GET.
request.Method = "GET";
// Get the response.
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
using (Stream responseStream = response.GetResponseStream())
{
using (StreamReader reader = new StreamReader(responseStream))
{
using (StreamWriter writer = new StreamWriter(fileName, false))
{
writer.Write(reader.ReadToEnd());
writer.Flush();
writer.Close();
}
}
responseStream.Close();
}
response.Close();
}
}
but the downloaded file only contains:
Your report is ready and will download to your Web browser in a few moments.
if I paste the link in chrome, it shows me a web page with : Your report.... and then starts the download.
Thank you so much for all the help!
Update: i did the Chrome crtl+shift+i -> network
the url of the reports is : whatever.com/p2pd/servlet/dispatch/gd/CAFS3c00000054FAAAACBugIFfTwbt-vZG2RFR7xOa6-wlAebBE523zHThH-tlqz0TrwhgYlE_H4sIAAAAAAAAALMODfLxdNFQ8svyNPXNyq-wrQqt9A2JLPcNcaz0q-Kt8s*KNPGtcrRV0gQAGDKw6yoAAAA_/
if i log in on ie and paste the url, it shows me a firewall error.. was looking at the session info's to see it it puts them in the link which it does not.
This is the heaeder Information:
GET /p2pd/servlet/dispatch/gd/CAFS3c00000054FAAAACBugIFfTwbt-vZG2RFR7xOa6-wlAebBE523zHThH-tlqz0TrwhgYlE_H4sIAAAAAAAAALMODfLxdNFQ8svyNPXNyq-wrQqt9A2JLPcNcaz0q-Kt8s*KNPGtcrRV0gQAGDKw6yoAAAA_/ HTTP/1.1
Host: whatever.com
Connection: keep-alive
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.94 Safari/537.4
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
Referer: https://whatever.com/p2pd/servlet/dispatch
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
Cookie: cam_passport=101:1212028e-a300-b0b0-9a59-6b86b56842dd:2388506829; cea-ssa=false; usersessionid=AQgAAAAZQaJQGUGiUAoAAADgMgQRkOeDfHCJFAAAACBugIFfTwbt/vZG2RFR7xOa6/wlFAAAAAhIMT47wEMbibXlyTAd0JuxNeln; CRN=listViewSeparator%3Dnone%26displayMode%3Dlist%26timeZoneID%3DCST%26format%3DHTML%26automaticPageRefresh%3D30%26columnsPerPage%3D3%26productLocale%3Den%26useAccessibilityFeatures%3Dfalse%26showWelcomePage%3Dtrue%26showOptionSummary%3Dfalse%26showHiddenObjects%3Dfalse%26contentLocale%3Den%26skin%3Dcorporate%26linesPerPage%3D15%26; userCapabilities=7c6d%3B6f%3Bff071efa%26ARQAAAAgboCBX08G7f72RtkRUe8Tmuv8JQBBkqOE98nKAPC1mu7HFx2kwsKb; caf=CAFW000000b0Q0FGQTNjMDAwMDAwM2FGQUFBQUNCdWdJRmZUd2J0LXZaRzJSRlI3eE9hNi13bFRtOGJUc0pHalZqSW1mSWZ0VHg3emhkKnpMOF8zNzU2MTJ8MTAxOjEyMTIwMjhlLWEzMDAtYjBiMC05YTU5LTZiODZiNTY4NDJkZDoyMzg4NTA2ODI5; cc_session=s_cc:|s_conf:na|s_sch:td|s_hd:sa|s_serv:na|s_disp:na|s_set:|s_dep:na|s_dir:na|s_sms:dd|s_ct:sa|s_cs:sa|s_so:sa|e_hp:CAMID(*22eBO*3au*3a11842*22)|e_proot:Public*20Folders|prootid:i9E956E6B64DA4217A97F144A433887C1|e_mroot:My*20Folders|mrootid:iD973C48427A94A9AAFB17F9016C8A62A|e_mrootpath:CAMID(*22eBO*3au*3a11842*22)*2ffolder*5b*40name*3d*27My*20Folders*27*5d|e_user:FirstName*20LastName|cl:en|dcid:i9E956E6B64DA4217A97F144A433887C1|show_logon:false|uig:|ui:|write:true|eom:0|pp:2388506829|cachestamp:2012-11-06T07:46:19; ARAHHC-eBO=ARAHHC-Arka-eBO2
100 - Continue? - Mike Perrenoud