Earlier using C# httpclient data extraction and calculation was easy. But recent restriction in header by yahoo finance resulted error in c# coders.
There is a solution to make it work by adding header to your httpclient properties.
1. Declare httpclient
Code: Select all
var httpClient = new HttpClient();
Code: Select all
httpClient.DefaultRequestHeaders.Add("User-Agent",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0");
Adding user-agent in header file of httpclient request yahoo finance restrictions can be eliminated.
Thanks
Admin