I created a Unit Test class for testing a simple HTTPS request
[TestMethod]
public async Task TestMethod1()
{
string destination = "...";
string message = "..";
string accountUsername = "..";
string accountPassword = "..";
string senderPhoneNumber = "...";
HttpStatusCode response = await SMSProvider.Send(destination, message, accountUsername, accountPassword, senderPhoneNumber);
Assert.AreEqual(HttpStatusCode.GatewayTimeout, response);
}
And the SMS Provider is a Library class
public static async Task<HttpStatusCode> Send(String destination, String message, String accountUsername, String accountPassword, String senderPhoneNumber)
{
HttpClient client = new HttpClient();
var values = new Dictionary<string, string>
{
{ "username", accountUsername },
{ "password", accountPassword },
{ "src", senderPhoneNumber },
{ "dst", destination },
{ "text", message },
{ "srr", "3" }
};
var content = new FormUrlEncodedContent(values);
HttpStatusCode responseStatus = HttpStatusCode.Accepted;
try
{
var response = await client.PostAsync("https:SPECIFIC-URL-HERE", content);
var responseString = await response.Content.ReadAsStringAsync();
responseStatus = response.StatusCode;
}
catch (WebException we)
{
string error = we.ToString();
}
catch (Exception e)
{
string error = e.ToString();
}
return responseStatus;
}
However it throws the following error
System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The request was aborted: Could not create SSL/TLS secure channel.
How can i send an HTTPS request? Do I need a certificate or something?