I used this guide: https://www.codeproject.com/Tips/497123/How-to-make-REST-requests-with-Csharp in order to perform a simple HTTP request. What should I change in order to make an HTTPS request?
Asked
Active
Viewed 1,486 times
0
-
1change the URL to https – Crowcoder Jun 18 '17 at 15:42
1 Answers
0
I don't think you need to use five years old samples for such things. There are many libraries that support easy REST API calls, one of the most popular is RestSharper. However, it has no changes since last year, seems having issues with maintainers. However it is still moer usable and supports async/await
.
To make a call via SSL all you need to do is indeed use https://
in the URL as @Crowcoder suggest in the comment.

Alexey Zimarev
- 17,944
- 2
- 55
- 83
-
ty! but it still dosen't work :( System.Net.WebException: 'The underlying connection was closed: An unexpected error occurred on a send.' – Nevo Mashiach Jun 18 '17 at 16:06
-
1May be you call to a site that uses self-signed certificate? Can you open the URL you are trying to call in the browser, without any warnings or errors and the browser shows that the connection is secure? – Alexey Zimarev Jun 18 '17 at 16:07
-
-
That is probably an issue because by default self-signed certificates do not play well and this is by design, you really want SSL to be secure and signed, this is why we have CAs for. RestSharp allows you to use the callback to fix it as described here: https://stackoverflow.com/questions/10397736/restsharp-ignore-ssl-errors – Alexey Zimarev Jun 19 '17 at 12:04
-
Can I just use my own certificate? (lets say via X509Certificate) – Nevo Mashiach Jun 19 '17 at 12:24