Manage global lists of Azure DevOps (TFS) by code

Viewed 14

I can export and import global list with witadmin.

witadmin exportgloballist /collection:http://imtfs:8080/tfs/DefaultCollection /f:c:\temp\globallist.xml
witadmin importgloballist /collection:http://imtfs:8080/tfs/DefaultCollection /f:c:\temp\globallist.xml

Can I do the same by code? Can I do it by C# with Microsoft.TeamFoundationServer.Client? Can I do it with REST?

1 Answers

Yes, you can use REST API: https://learn.microsoft.com/en-us/rest/api/azure/devops/processes/lists?view=azure-devops-rest-6.0

Or Team foundation Client:

WorkItemTrackingProcessHttpClient ProcessHttpClient = Connection.GetClient<WorkItemTrackingProcessHttpClient>();

var lists = ProcessHttpClient.GetListsMetadataAsync().Result;
var list = ProcessHttpClient.GetListAsync(lists[1].Id).Result;
list.Items.Add("PREPROD");
var updatedList = ProcessHttpClient.UpdateListAsync(list, list.Id).Result;

The result:

enter image description here

Related