在使用HttpWebRequest请求API的时候总是报错,后来发现是需要设置传输协议。
在代码里面创建Request之前添加如下代码即可:
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
ServicePointManager.SecurityProtocol = (SecurityProtocolType)192 | (SecurityProtocolType)768 | (SecurityProtocolType)3072;
更多文章请扫码关注公众号,有问题的小伙伴也可以在公众号上提出。