PermId API calling error

using (var client = new HttpClient())

{

var req = client.GetAsync("https://permid.org/1-55835312773?access-token=<token>&format=json-ld").Result;

Console.WriteLine(req.Content.ReadAsStringAsync().Result);

}


During this connection establishment only- We are getting below error message exception:

image


image

Best Answer

Answers

  • @alexandra.hening

    I found a solution on the StackOverflow.

    If I use .NET Framework 4.5, the code looks like this:

    using System;
    using System.Net;
    using System.Net.Http;

    namespace ConsoleApp12
    {
        class Program
        {
            static void Main(string[] args)
            {
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
                using (var client = new HttpClient())

                {

                    var req = client.GetAsync("https://permid.org/1-55835312773?access-token=<token>&format=json-ld").Result;

                    Console.WriteLine(req.Content.ReadAsStringAsync().Result);

                }
            }
        }
    }