C# POST request to webapi using a console program
<p>I have a web api that I can access successfully through a browser :-</p>

<p><a href="https://127.0.0.1:8443/ncrApi" rel="nofollow">https://127.0.0.1:8443/ncrApi</a></p>

<p>I am trying to create a simple console program in C# using VS2015 to send data and receive a response using http POST.</p>

<p>Here is what I have so far:-</p>

<pre><code>using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;

namespace WebSample
{

    class ApiSendData
    {
        public string ApiFunction { get; set; }
        public string DppName { get; set; }
        public string ClearData { get; set; }
        public string DppVersion { get; set; }
    }



    class Program
    {
        static void Main(string[] args)
        {
            // The Main function calls an async method named RunAsync 
            // and then blocks until RunAsyncc completes.
            RunAsync().Wait();
        }

        static async Task RunAsync()
        {
            using (var client = new HttpClient())
            {
                // This code sets the base URI for HTTP requests, 
                // and sets the Accept header to "application/json", 
                // which tells the server to send data in JSON format.
                client.BaseAddress = new Uri("https://localhost:8443/ncrApi");
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));


                // HTTP POST
                var datatobeSent = new ApiSendData()
                                    {
                                        ApiFunction ="NcrSecureData",
                                        DppName ="CSampleCustomer",
                                        DppVersion ="Latest",
                                        ClearData ="1234567890"
                                    };

                HttpResponseMessage response = await client.PostAsJsonAsync("ncrApi", datatobeSent);

                if (response.IsSuccessStatusCode)
                {
                    // Get the URI of the created resource.
                    Uri ncrUrl = response.Headers.Location;

                    // do whatever you need to do here with the returned data //


                }
            }
        }
    }
}
</code></pre>

<p>However I am getting an error on the HttpResonseMessage response statement....{"An error occurred while sending the request."}
{"The request was aborted: Could not create SSL/TLS secure channel."}</p>

<p>I suspect it is because I am not correctly understanding the the client.BaseAddress and the HttpResponseMessage response statements.</p>

<p>Here is what I have been following:-
<a href="http://www.asp.net/web-api/overview/advanced/calling-a-web-api-from-a-net-client" rel="nofollow">http://www.asp.net/web-api/overview/advanced/calling-a-web-api-from-a-net-client</a></p>