HI,
Following code is failing at WebClient statement. I am not able to get the csv from API.
- private static async Task<double?> GetStockPriceAsync(string symbol)
- {
- if (string.IsNullOrWhiteSpace(symbol))
- return null;
- string url = $"http://finance.yahoo.com/d/quotes.csv?s={symbol}&f=l1" ;
- string csv;
- using (WebClient client = new WebClient())
- {
- csv = await client.DownloadStringTaskAsync(url).ConfigureAwait(false);
- }
- string line = csv.Split('\n')[0];
- string price = line.Split(',')[1];
- double result;
- if (double.TryParse(price, out result))
- return result;
- return null;
- }


Amit GuptaRank #190 · 12.8K reputationPosted Apr 24, 2017, 3:24 AM EDT
Ms_ DevRank #8,652 · 218 reputationPosted Apr 24, 2017, 3:38 AM EDT
Amit GuptaRank #190 · 12.8K reputationPosted Apr 24, 2017, 3:54 AM EDT