1

我想使用 Classic ASP 中的 Pingdom REST API,但是下面的代码:-

' setup the URL
baseUrl = "https://api.pingdom.com/api/2.0/checks"

' setup the request and authorization
Set http = Server.CreateObject("MSXML2.ServerXMLHTTP")
http.open "GET", baseUrl, False 
http.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
http.setRequestHeader "userpwd", "aaaaaaaaaaaaaaaaaaaaaaa:bbbbbbbbbbb"
http.setRequestHeader "App-Key", "ccccccccccccccccccccccccccccccc"

' send the HTTP data
http.send 

给我错误:-

{"error":{"statuscode":401,"statusdesc":"Unauthorized","errormessage":"User credentials missing"}}

所以我的身份验证没有正确传递,看起来它不应该在请求头中传递,但我不确定应该如何完成。

谢谢

感谢 Alex K. 并为了他人的利益,正确的语法是:-

' setup the URL
baseUrl = "https://api.pingdom.com/api/2.0/checks"

Response.Write fullUrl
' setup the request and authorization
Set http = Server.CreateObject("MSXML2.ServerXMLHTTP")
http.open "GET", baseUrl, False, "emailaddress", "password"
http.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
http.setRequestHeader "App-Key", "keykeykeykeykeykeykeykeykeykey"

' send the HTTP data
http.send 

:-)

4

1 回答 1

2

https://api.pingdom.com/api/2.0/checks正在使用基本身份验证,因此您需要在.open调用中传递您的凭据。

于 2012-01-17T13:45:47.293 回答