Error accessing end-point using restsharp

Asked

Viewed 69 times

0

I have an API (.NET Framework 4.8) that communicates with another layer (.NET Framework 4.0) where I have developed a method that persists an information in the database, and at the end triggers ANOTHER API (third party) to send an email. When I run the application on Windows 10 it works normally, but when trying to run on Windows 7 (in the IDE) and on Windows 2012 (published) the answer returns me status code 0 with the following error "The request was aborted: Could not create SSL/TLS Secure Channel."

Encoding I’m using to make the call at the end-point:

Dim request As New RestRequest(endpoint, type)

request.RequestFormat = DataFormat.Json
request.AddHeader("Content-Type", "application/json")
request.AddHeader("sourceToken", _sourceToken)

If Not IsNothing(body) Then request.AddJsonBody(body)
ServicePointManager.SecurityProtocol = Tls12

1 answer

-3

I had a similar problem involving different versions of windows and what helped me was to add this line:

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;

But your problem may be because of Addheader. It is recommended to use Irestclient.Useragent in place, second restsharp documentation

Browser other questions tagged

You are not signed in. Login or sign up in order to post.