繁体   English   中英

.NET core azure function app restsharp restclient throw 无法建立 SSL 连接

[英].NET core azure function app restsharp restclient throw The SSL connection could not be established

我有 .net core azure 功能应用程序,

到目前为止,下面的代码运行良好。

现在我收到这个错误 -

无法建立 SSL 连接,请参阅内部异常。 无法从传输连接读取数据:远程主机强行关闭了现有连接。

var client = new RestClient("https://test.salesforce.com/services/oauth2/token");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
request.Parameters.Clear();
request.AddParameter("grant_type", "password");
request.AddParameter("username", "user");
request.AddParameter("password", "123");
request.AddParameter("client_id", "qw2");
request.AddParameter("client_secret", "23s");
response = client.Execute(request);

只需添加@Neo 的评论作为帮助社区成员的答案:

我们需要在salesforce中加入ipaddres range来解决这个问题。

在执行其余部分之前添加此内容

System.Net.ServicePointManager.Expect100Continue = false;

如果仍然出现错误,通过不同的身份验证,下面的身份验证是基本的,如果你想要承载更改身份验证类型。

 client.Authenticator = new HttpBasicAuthenticator(Username), (Password);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM