Skip to content

Instantly share code, notes, and snippets.

@waldyrfelix
Created October 30, 2012 22:09
Show Gist options
  • Save waldyrfelix/3983405 to your computer and use it in GitHub Desktop.
Save waldyrfelix/3983405 to your computer and use it in GitHub Desktop.
Requisição HTTP Basic Authorization com C#
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Add("Authorization", "Basic d2FsZHlyOjEyMw==");
var strings = await client.GetAsync("/api/values");
var strResult = await strings.Content.ReadAsStringAsync();
var serializer = new JavaScriptSerializer();
var result = serializer.Deserialize<string[]>(strResult);
foreach (var s in result)
{
Console.WriteLine(s);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment