質問

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 

:-)

役に立ちましたか?

解決

https://api.pingdom.com/api/2.0/checks 基本認証を使用しているため、資格情報を渡す必要があります .open 電話。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top