0
votes

I'd like to get a list of all the iterations for a given project in a Azure DevOps repository, using the .NET API.

Is there any example of how to do this? The current documentation (https://docs.microsoft.com/en-us/dotnet/api/microsoft.teamfoundation.work.webapi.workhttpclientbase.getteamiterationsasync?view=azure-devops-dotnet) is pretty thin.

1

1 Answers

0
votes

Below is a working example of how to achieve this.

You need to reference 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;
}