Web Services 如何在Visual Studio 2019上向ODATA Microsoft动态Web服务添加凭据

pexxcrt2  于 2022-11-15  发布在  其他
关注(0)|答案(1)|浏览(135)

在浏览器上使用Microsoft动态Web服务链接时,会提示凭据,如下图

所示
问题是如何将此凭据传递给Visual studio以避免未授权响应

我试过:

Authorisation:Basic
username: valid username
password: valid password

在“自定义标题”文本框中,选中“包括自定义http标题”

gt0wga4j

gt0wga4j1#

this related post中所述,您可以按如下方式提供用户凭据:

var client = new RestClient(Url);
var request = new RestRequest(Method.GET);
client.FollowRedirects = true;
client.Timeout = -1;
client.PreAuthenticate = true;
request.Credentials = new NetworkCredential(User, Password);

您已将Dynamics系统的域名替换为它的IP地址。请确保该服务实际处于活动状态。是否存在阻止用户调用此服务的访问限制?请检查服务器端的事件日志条目。
使用postman测试连接/凭据。这样的测试可以排除代码之外的问题。如果postman能够执行成功的调用,则代码就是罪魁祸首。
服务URL中的Campany拼写不正确?

相关问题