Skip to content

Instantly share code, notes, and snippets.

Created May 10, 2020 05:18
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
[Azure DevOps] REST API で作業項目を取得する
using Newtonsoft.Json;
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
namespace GetWorkItem
class Program
static async Task Main(string[] args)
var pat = "";
var organization = "";
var project = "";
var id = 0;
var httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes($":{pat}")));
var r = await httpClient.GetAsync($"{organization}/{project}/_apis/wit/workitems/{id}?api-version=5.1");
var json = await r.Content.ReadAsStringAsync();
public static string FormatJson(string jsonText)
var o = JsonConvert.DeserializeObject(jsonText);
return JsonConvert.SerializeObject(o, new JsonSerializerSettings { Formatting = Formatting.Indented });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment