Facebook
From Mature Plover, 4 Years ago, written in C#.
Embed
Download Paste or View Raw
Hits: 236
  1. public static async void GetProjects()
  2. {
  3.         try
  4.         {
  5.                 var personalaccesstoken = "token";
  6.  
  7.                 using (HttpClient client = new HttpClient())
  8.                 {
  9.                         client.DefaultRequestHeaders.Accept.Add(
  10.                                 new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
  11.  
  12.                         client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic",
  13.                                 Convert.ToBase64String(
  14.                                         System.Text.ASCIIEncoding.ASCII.GetBytes(
  15.                                                 string.Format("{0}:{1}", "", personalaccesstoken))));
  16.  
  17.                         using (HttpResponseMessage response = await client.GetAsync(
  18.                                                 "https://dev.azure.com/fildnet/_apis/projects"))
  19.                         {
  20.                                 response.EnsureSuccessStatusCode();
  21.                                 string responseBody = await response.Content.ReadAsStringAsync();
  22.                                 Console.WriteLine(responseBody);
  23.                         }
  24.                 }
  25.         }
  26.         catch (Exception ex)
  27.         {
  28.                 Console.WriteLine(ex.ToString());
  29.         }
  30. }

Replies to Untitled rss

Title Name Language When
Re: Untitled Capacious Porcupine csharp 4 Years ago.