1

I have to receive the API from Pingdom. The address is https://api.pingdom.com

How can I in .NET do a http get when it is https? Google gives me nothing to work with :(

Best regards

UPDATE::

Thanks for help.. Trying with PowerShell:

$NC = New-Object System.Net.NetworkCredential("USER", "PASS")
$CC = New-Object System.Net.CredentialCache
$CC.Add("api.pingdom.com", 443, "Basic", $NC)


$webclient = [System.Net.WebRequest]::Create("https://api.pingdom.com")
$webclient.Credentials = $CC
$webclient.PreAuthenticate = $true
$webclient.Method = "POST"

$webclient.GetResponse()

I get the error: Exception calling "GetResponse" with "0" argument(s): "The remote server returned an error: (401) Unauthorized."

Any good advice?

user1281991
  • 763
  • 1
  • 12
  • 34
  • there is an example .net app which uses the API, you can download the visual studio project here: http://www.pingdom.com/services/api-applications/ – Colin Pickard Jul 25 '12 at 11:53

2 Answers2

2

Basically,

http://www.pingdom.com/services/api-documentation-rest/

The authentication method for user credentials is HTTP Basic Access Authentication (encrypted over HTTPS). This means you will provide your credentials every time you make a request. No sessions are used.

HTTP Basic Access Authentication is well documented both here and on MSDN.

This answer together with the API docs should get you started down the right path.

https://stackoverflow.com/a/1127295/64976

Assuming you use a WebRequest, you attach a CredentialCache to your request:

NetworkCredential nc = new NetworkCredential("user", "password");
CredentialCache cc = new CredentialCache();
cc.Add("www.site.com", 443, "Basic", nc);

The CredentialCache is used to be able to set Basic authentication.

Community
  • 1
  • 1
J. Steen
  • 15,470
  • 15
  • 56
  • 63
1

You should be able to set the credentials of the webclient and then any time a login is needed, it will supply what you gave it.

WebClient webClient = new WebClient();
webClient.Credentials = new System.Net.NetworkCredential("UserName", "Password", "Domain");
steveg89
  • 1,807
  • 2
  • 15
  • 29