curl -u equivalent in .Net WebClient class
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开发者_StackOverflow中文版't work by the way.
Thanks.
This is the solution:
webRequest.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(authbytes));
authBytes is the password converted to byte array.
Try using a CredentialCache
精彩评论