I have a requirement to Get VSO workitem using C# Rest API call. I'm unable to figure out how to get the token for my http request. Below is what I have. Can someone give me the code to get the token to authenticate to VSO.
using System;
using System.Net.Http;
using System.Threading.Tasks;
namespace GetVSOTask
{
class Program
{
static async Task Main(string[] args)
{
string token = "?????";
var httpClient = new HttpClient
{
BaseAddress = new Uri("https://dev.azure.com/")
};
string URI = $"Microsoft/OSGS/_apis/wit/workitems/31054512?&api-version=6.0";
httpClient.DefaultRequestHeaders.Remove("Authorization");
httpClient.DefaultRequestHeaders.Add("Authorization", "Bearer " + token);
HttpResponseMessage response = await httpClient.GetAsync(URI).ConfigureAwait(false);
var HttpsResponse = await response.Content.ReadAsStringAsync();
Console.WriteLine(HttpsResponse);
Console.ReadLine();
}
}
}