VSTS - 无法获取迭代列表

VSTS - Unable to get Iteration list

我正在尝试使用以下 REST API、

获取我的 VSTS 项目迭代列表
        string _personalAccessToken = "mypersonalAccessToken"; // this PAT has Project and team (read, write, and manage) and Work items (read and write) scope 
        string _credentials = Convert.ToBase64String(Encoding.ASCII.GetBytes(string.Format("{0}:{1}", "", _personalAccessToken)));

        using (var client = new HttpClient())
        {            
            client.BaseAddress = new Uri("https://*myUserAccount*.visualstudio.com/");
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", _credentials);

            var response = client.GetAsync("DefaultCollection/*MyProjectName*/*MyTeamName*/_apis/work/TeamSettings/Iterations?api-version=v2.0-preview.1").Result;

            Console.WriteLine(response.Content.ReadAsStringAsync().Result);                
        }

我的 REST 调用正在执行,没有任何错误(返回 200 代码),值为空。虽然在我的项目中,我们至少有 50 次迭代,但我没有使用上面的代码获取那些。

我不确定我哪里出错了。任何帮助将不胜感激。

代码没问题

参考这些步骤来检查该团队的迭代。

  1. 转到该团队的管理页面
  2. Select 工作
  3. 检查迭代列表
  4. (可选)单击 Select 次迭代以添加迭代。

更新:

如果您省略团队名称,它将检索默认团队的迭代。

默认团队:转到团队项目的管理页面 > 概述 > 更改默认团队

Select 默认团队的迭代:转到团队项目的管理页面 > 工作 > 迭代> 单击默认团队的设置。

如果要获取团队项目的所有迭代,可以使用get the root iteration tree REST API or you can use this code directly (add/install Microsoft Team Foundation Server Extended Client包):

 var u = new Uri("https://starain.visualstudio.com");
 VssCredentials c = new VssCredentials(new Microsoft.VisualStudio.Services.Common.VssBasicCredential(string.Empty, "[pat]"));
            var connection = new VssConnection(u, c);
            var workItemTracking = connection.GetClient<WorkItemTrackingHttpClient>();
 Microsoft.TeamFoundation.Core.WebApi.ProjectHttpClient projClient = connection.GetClientAsync<Microsoft.TeamFoundation.Core.WebApi.ProjectHttpClient>().Result;
           var projects= projClient.GetProjects().Result;
            foreach(var p in projects.Where(pro=>pro.Name=="Scrum2015"))
            {
                var iteration = workItemTracking.GetClassificationNodeAsync(project: p.Name, structureGroup: Microsoft.TeamFoundation.WorkItemTracking.WebApi.Models.TreeStructureGroup.Iterations, depth: 5).Result;
                GetIterations(iteration);
            }


 static void GetIterations(Microsoft.TeamFoundation.WorkItemTracking.WebApi.Models.WorkItemClassificationNode currentIteration)
        {
            Console.WriteLine(currentIteration.Name);
            if(currentIteration.Children!=null)
            {
                foreach (var ci in currentIteration.Children)
                {
                    GetIterations(ci);
                }
            } 
        }