gpt4 book ai didi

c# - .NET https身份验证(Pingdom API)

转载 作者:行者123 更新时间:2023-12-03 01:21:56 25 4
gpt4 key购买 nike

我必须从Pingdom接收API。地址是https://api.pingdom.com

如果HTTP是https,我如何在.NET中获取http?谷歌给我没有什么可以使用:(

最好的祝福

更新::

感谢您的帮助。尝试使用PowerShell:

$NC = New-Object System.Net.NetworkCredential("USER", "PASS")
$CC = New-Object System.Net.CredentialCache
$CC.Add("api.pingdom.com", 443, "Basic", $NC)


$webclient = [System.Net.WebRequest]::Create("https://api.pingdom.com")
$webclient.Credentials = $CC
$webclient.PreAuthenticate = $true
$webclient.Method = "POST"

$webclient.GetResponse()

我收到错误:参数为“0”的异常调用“GetResponse”:“远程服务器返回错误:(401)未经授权。”

有什么好的建议吗?

最佳答案

基本上,

http://www.pingdom.com/services/api-documentation-rest/

The authentication method for user credentials is HTTP Basic Access Authentication (encrypted over HTTPS). This means you will provide your credentials every time you make a request. No sessions are used.


HTTP基本访问身份验证在此处和MSDN上都有详细记录。
该答案与API文档一起应该可以帮助您正确地开始工作。

https://stackoverflow.com/a/1127295/64976

Assuming you use a WebRequest, you attach a CredentialCache to your request:

NetworkCredential nc = new NetworkCredential("user", "password");
CredentialCache cc = new CredentialCache();
cc.Add("www.site.com", 443, "Basic", nc);
CredentialCache用于设置基本身份验证。

关于c# - .NET https身份验证(Pingdom API),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11648988/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com