Pingdom Rest API di Classic Asp
-
29-10-2019 - |
Domanda
Vorrei usare l'API REST Pingdom di ASP classica, ma il seguente codice:-
' 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
mi dà l'errore:-
{"error":{"statuscode":401,"statusdesc":"Unauthorized","errormessage":"User credentials missing"}}
Quindi la mia autenticazione non viene passata correttamente e sembra che non dovrebbe essere passata nella richiesta di richiesta, ma non sono sicuro di come dovrebbe essere fatto.
Grazie
Grazie per Alex K. e per il vantaggio degli altri, la sintassi corretta è:-
' 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
:-)
Soluzione
https://api.pingdom.com/api/2.0/checks sta utilizzando l'autenticazione di base, quindi è necessario passare le credenziali in .open
chiamata.
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow