我想使用 .NET API 获取 Azure DevOps 存储库中给定项目的所有迭代列表。
有没有如何做到这一点的例子?当前的文档(https://docs.microsoft.com/en-us/dotnet/api/microsoft.teamfoundation.work.webapi.workhttpclientbase.getteamiterationsasync?view=azure-devops-dotnet)非常薄。
我想使用 .NET API 获取 Azure DevOps 存储库中给定项目的所有迭代列表。
有没有如何做到这一点的例子?当前的文档(https://docs.microsoft.com/en-us/dotnet/api/microsoft.teamfoundation.work.webapi.workhttpclientbase.getteamiterationsasync?view=azure-devops-dotnet)非常薄。
下面是一个如何实现这一点的工作示例。
你需要参考Microsoft.TeamFoundation.Work.WebApi
。
public async Task<List<TeamSettingsIteration>> GetProjectIterations(string serverUrl, string projectName)
{
var uri = new Uri(serverUrl);
var creds = new VssClientCredentials(new WindowsCredential(true), new VssFederatedCredential(true), CredentialPromptType.PromptIfNeeded);
var azureDevopsConnection = new VssConnection(uri, creds);
await azureDevopsConnection.ConnectAsync();
WorkHttpClient azureDevOpsWorkHttpClient = azureDevopsConnection.GetClient<WorkHttpClient>();
TeamContext teamContext = new TeamContext(projectName);
List<TeamSettingsIteration> results= await azureDevOpsWorkHttpClient.GetTeamIterationsAsync(teamContext);
return results;
}