我想使用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"}}因此,我的身份验证没有正确通过,而且看起来不应该在requestheader中通过,但我不确定应该如何完成。
谢谢
感谢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 :-)
发布于 2012-01-17 21:45:47
https://api.pingdom.com/api/2.0/checks使用基本身份验证,因此您需要在.open调用中传递凭据。
https://stackoverflow.com/questions/8895533
复制相似问题