WebRequestHandler handler = new WebRequestHandler();
                try
                {
                    X509Certificate2 certificate = new X509Certificate2(System.IO.File.ReadAllBytes(ConfigurationManager.AppSettings["webapicertpath"]), ConfigurationManager.AppSettings["webapicertpwd"]); ;
                    handler.ClientCertificates.Add(certificate);
                    ServicePointManager.ServerCertificateValidationCallback =
                        (object sender, X509Certificate certificate1, X509Chain chain, SslPolicyErrors sslPolicyErrors) =>
                        {
                            return true;
                        };
                }
                catch
                {
                }
                httpClient = new HttpClient(handler);

  to fetch data with REST httpclient, just utilize code below:

                case "get":
                    result = httpClient.GetAsync(url).Result.Content.ReadAsStringAsync().Result;
                    break;
                case "post":
                    result = httpClient.PostAsync(url, content).Result.Content.ReadAsStringAsync().Result;
                    break;
                case "put":
                    result = httpClient.PutAsync(url, content).Result.Content.ReadAsStringAsync().Result;
                    break;
                case "delete":
                    result = httpClient.DeleteAsync(url).Result.Content.ReadAsStringAsync().Result;
                    break;
                default:
                    break;

  

相关文章:

  • 2021-07-18
  • 2022-12-23
  • 2021-07-22
  • 2022-12-23
  • 2021-08-28
  • 2021-08-08
  • 2022-12-23
  • 2021-07-31
猜你喜欢
  • 2022-12-23
  • 2021-05-21
  • 2022-01-09
  • 2021-12-03
  • 2021-08-03
  • 2021-12-23
  • 2021-09-15
相关资源
相似解决方案