0

the code below is working on localhost but failing from the server.

environment: .NET Framework 4.5 hosted on IIS 8.5 Windows Server core 2012 (AWS)

//using System.Net;
//using RestSharp;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
ServicePointManager.Expect100Continue = true;

restClient = new RestClient("https://restapi.myapi.com/api/");
var request = new RestRequest("emailconfirmation/{id}", Method.GET);

request.AddParameter(new Parameter
    {
       Name = "id",
       Value = key,
       Type = ParameterType.UrlSegment
    });

return restClient.Execute(request);
Nick
  • 1
  • 2
  • What type of errors or logs are you getting on AWS? – Keyur Ramoliya Oct 01 '21 at 10:38
  • Does this answer your question? -> https://stackoverflow.com/q/10822509 – Keyur Ramoliya Oct 01 '21 at 10:40
  • actually the only error I have occurs when i run the request from the website hosted in the server, not sure it is linked to AWS. my error : `System.Net.WebException: The request was aborted: Could not create SSL/TLS secure channel. at System.Net.HttpWebRequest.GetResponse() at RestSharp.Http.GetRawResponse(HttpWebRequest request) at RestSharp.Http.GetResponse(HttpWebRequest request)` – Nick Oct 01 '21 at 10:52

1 Answers1

0

Solved by setting up a new environment with a more recent IIS and windows server.

New environment: IIS 10.0 Windows Server 2019.
Old environment: IIS 8.5 Windows Server core 2012.

I think the old environment was failing due to a security configuration on the server side which was making the API failing to request.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Nick
  • 1
  • 2