C#C
C#12mo ago
bhavish

✅ Request error: The SSL connection could not be established, see inner exception.

using System.Text;

var client = new HttpClient();

// Set up the request
var request = new HttpRequestMessage
{
    Method = HttpMethod.Post,
    RequestUri = new Uri("https://<my-domain>.azurewebsites.net/company/products/notifier/email"),
    Content = new StringContent(
        @"{
                    ""fromMail"": ""thejeshm@ivoyant.com"",
                    ""fromName"": ""IHRM-Team"",
                    ""to"": [""bhavishp@bhavish.com""],
                    ""subject"": ""some message"",
                    ""templateId"": ""d-401bd3782f974c1da24db450f5f1eb86"",
                    ""props"": {
                        ""name"": ""GUS""
                    }
                }",
        Encoding.UTF8,
        "application/json"
    )
};

// Set headers
request.Headers.Add("accept", "*/*");

try
{
    // Send the request
    var response = await client.SendAsync(request);

    // Ensure the response indicates success
    response.EnsureSuccessStatusCode();

    // Print the response content
    var responseContent = await response.Content.ReadAsStringAsync();
    Console.WriteLine($"Response: {responseContent}");
}
catch (HttpRequestException e)
{
    Console.WriteLine($"Request error: {e.Message}");
}

I am using a mail sender API which is working in other language scripts and postman but not in C#. and giving the above mentioned error
Was this page helpful?