Pingdom REST API from Classic ASP

1.5k views Asked by At

I would like to use the Pingdom REST API from Classic ASP, but the following code:-

' 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 

gives me the error:-

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

so my authentication isnt being passed correctly, and it looks like it should NOT be passed in the requestheader, but I'm not sure how it should be done.

Thanks

Thanks for Alex K. and for the benefit of others, the correct syntax is:-

' 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 

:-)

1

There are 1 answers

0
Alex K. On BEST ANSWER

https://api.pingdom.com/api/2.0/checks is using Basic Authentication so you need to pass your credentials in the .open call.