是否可以通过.NET客户端库检索Azure DevOps选择列表信息?

时间:2020-08-26 03:21:43

标签: c# azure azure-devops azure-devops-rest-api

我正在使用.NET client libraries之类的Microsoft.TeamFoundationServer.Client来检索Azure DevOps中的工作项。

但是,尽管Azure DevOps Services REST API documentation中提到了它,但我找不到通过.NET客户端库获取选择列表信息的方法(请参见下图)

Get picklist information using the Azure DevOps Services REST API

是否可以通过.NET客户端库(例如通过Microsoft.TeamFoundationServer.Client)检索选择列表信息?

1 个答案:

答案 0 :(得分:1)

在此处检查示例:https://github.com/microsoft/azure-devops-dotnet-samples/blob/main/ClientLibrary/Samples/WorkItemTrackingProcess/ProcessesSample.cs

            string _personalAccessToken = "xxxxxx";
            VssBasicCredential credentials = new VssBasicCredential("", _personalAccessToken);
            var connection = new VssConnection(new Uri(@"https://dev.azure.com/xxx"), credentials);

            WorkItemTrackingProcessHttpClient client = connection.GetClient<WorkItemTrackingProcessHttpClient>();

            Console.Write("Getting list of processes....");

            List<ProcessInfo> list = client.GetListOfProcessesAsync().Result;

            if (list == null || list.Count == 0)
            {
                Console.WriteLine("No processes found");
            }
            else
            {
                Console.WriteLine("Done");

                foreach (var item in list)
                {
                    Console.WriteLine("{0}    {1}    {2}", item.Name, item.TypeId, item.ReferenceName);
                }
            }