Facebook
From Capacious Porcupine, 5 Years ago, written in C#.
This paste is a reply to Untitled from Mature Plover - go back
Embed
Viewing differences between Untitled and Re: Untitled
public static async void GetProjects()
{
        try
        {
                var personalaccesstoken = "token";

                using (HttpClient client = new HttpClient())
                {
                        client.DefaultRequestHeaders.Accept.Add(
                                new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));

                        client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic",
                                Convert.ToBase64String(
                                        System.Text.ASCIIEncoding.ASCII.GetBytes(
                                                string.Format("{0}:{1}", "", personalaccesstoken))));

                        using (HttpResponseMessage response = await client.GetAsync(
                                                "https://dev.azure.com/fildnet/_apis/projects"))
                        {
                                response.EnsureSuccessStatusCode();
                                string responseBody = await response.Content.ReadAsStringAsync();
                                Console.WriteLine(responseBody);
                        }
                }
        }
        catch (Exception ex)
        {
                Console.WriteLine(ex.ToString());
        }
   public static void Main(string[] args)
        {

            GetProjects();

        }
}