2

The question explains it all but here is some more info. I am trying to use 4sq api with C# and need to send username password pair in every request. The API documentations says that "curl -u user:pass" does the job but how can I do it with WebClient? Don't have time to inspect the traffic, maybe someone knows about it...

WebClient.Credential doesn't work by the way.

Thanks.

skaffman
  • 398,947
  • 96
  • 818
  • 769
Élodie Petit
  • 5,774
  • 6
  • 50
  • 88
  • Should have searched before asking: webRequest.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(authbytes)); – Élodie Petit Oct 22 '10 at 12:33
  • If you found the solution, what about adding the answer yourself so others can benefit from it? :) – snemarch Oct 22 '10 at 12:33

2 Answers2

5

This is the solution:

webRequest.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(authbytes));

authBytes is the password converted to byte array.

Élodie Petit
  • 5,774
  • 6
  • 50
  • 88
1

Try using a CredentialCache

Onkelborg
  • 3,927
  • 1
  • 19
  • 22