Created
October 30, 2012 22:09
-
-
Save waldyrfelix/3983405 to your computer and use it in GitHub Desktop.
Requisição HTTP Basic Authorization com C#
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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