-2

I'm trying to download a .csv file off Etsy and I'm not sure why it's not working to just write

StreamReader reader = new StreamReader(WebRequest.Create("https://www.etsy.com/se-en/your/orders/sold.csv?csv-type=transaction-level&month=&year=2016").GetResponse().GetResponseStream());
string line;
while ((line = reader.ReadLine()) != null)
{
Console.WriteLine(line);
}

Or just

StreamReader reader = new StreamReader(WebRequest.Create("https://www.etsy.com/se-en/your/orders/sold.csv").GetResponse().GetResponseStream());
string line;
while ((line = reader.ReadLine()) != null)
{
Console.WriteLine(line);
}

I also tried using

using (var client = new WebClient())
{
client.Credentials = new NetworkCredential("login", "password");
client.DownloadFile("https://www.etsy.com/se-en/your/orders/sold.csv", @"c:\sold.csv");
}

But it keeps giving me http instead.

Adkit
  • 67
  • 1
  • 1
  • 7
  • Does this link redirect you to the download link ? – Niklas Sep 11 '16 at 14:40
  • @MichalHainc can you see this? https://stackoverflow.com/questions/48278333/php-curl-to-net-httprequest-files-uploading-to-server –  Jan 16 '18 at 11:21

1 Answers1

0

What is in HTML you get? As suggested, There may be cookie or token based auth. In that case, you would have to make two request, one on auth url to get an a appropriate cookie or token and second on download url with mentioned cookie or token. You should try this process manually in Chrome with debug and record actual request and responses you need.

johnymachine
  • 781
  • 2
  • 7
  • 28
  • I've never used cookies before but managed to figure out what I needed to do once I looked into it with the debug on chrome, so thank you. – Adkit Sep 12 '16 at 15:22