0

I have a little problem. I just want to extract the data from this website: https://api.nasdaq.com/api/calendar/splits?date=20200821

I've created a script but gives me that error: [c#] The request was aborted: Could not create SSL/TLS secure channel

WebClient client = new WebClient();
string downloadString = client.DownloadString("https://api.nasdaq.com/api/calendar/splits?date=20200821");

MessageBox.Show(downloadString);

What can I do?

georege
  • 3
  • 3
  • What's `textBox1.Text`? – user202729 Sep 21 '20 at 17:06
  • What is the value that `textBox1.Text` contains? – Robert Harvey Sep 21 '20 at 17:07
  • The website URL. @us – georege Sep 21 '20 at 17:07
  • Which is .......? – Robert Harvey Sep 21 '20 at 17:07
  • https://api.nasdaq.com/api/calendar/splits?date=20200821 as I said in the desc. – georege Sep 21 '20 at 17:08
  • Five years ago the industry decided to eliminate TLS 1.0/1.1 and use TLS 1.2/1.3. In June Microsoft pushed a security update to disable TLS 1.0/1.1 on Servers. Client now have to request TLS 1.2/1.3. So the version of TLS is based on your operating System, VS, and your code. So add before you webclient the following : System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls13; – jdweng Sep 21 '20 at 17:08
  • 1
    OK. Well, there are a number of reasons why the error message could be occurring. Have you checked https://stackoverflow.com/questions/2859790 and tried everything there? – Robert Harvey Sep 21 '20 at 17:09
  • Of course first i searched, then I asked, because I didnt found any answer. I will try jdweng solution. – georege Sep 21 '20 at 17:10
  • FYI: When I search [like this](https://duckduckgo.com/?q=c%23+The+request+was+aborted%3A+Could+not+create+SSL%2FTLS+secure+channel&ia=web) the linked question is the first result. – user202729 Sep 21 '20 at 17:12
  • TLS 11 gives that error, TLS 12 doesnt work, I already tried, no answer, and Tls13 doesnt even exists, – georege Sep 21 '20 at 17:12
  • What does "doesn't work" mean? What's the error message? (edit the question to add the error message, if any) See the answer below https://stackoverflow.com/a/48930280/5267751 for "If you don’t have .NET 4.5" – user202729 Sep 21 '20 at 17:21

1 Answers1

0

For this particular api you need to pass the date as a specific format YYYY-MM-DD. Try this url https://api.nasdaq.com/api/calendar/splits?date=2020-08-21.

Rob Smitha
  • 395
  • 5
  • 8
  • This is part of the issue, but it definitely won't cause HTTPS error. – user202729 Sep 21 '20 at 17:20
  • You're right. I initially thought the error was erroneous because of the malformed request, but after trying it in the browser, you should at least get a 400 Bad request response. Hope you get it straightened out. – Rob Smitha Sep 21 '20 at 18:04