如何通过Azure DevOps Services REST API获取可用的区域路径?

7

我无法在API中找到检索区域路径的方法。 我能够获取迭代路径但无法获取区域路径。

我实际上是使用C#包装器

我已尝试通过以下途径:

  • ProjectHttpClient.GetProject()
  • ProjectHttpClient.GetProjectPropertiesAsync();
  • WorkItemTrackingHttpClient.GetFieldAsync("System.AreaPath");
  • WorkItemTrackingHttpClient.GetWorkItemTypeFieldWithReferencesAsync();
  • 我还查看了WorkHttpClient,因为我从那里获得了迭代。
  • 我查看了文档,但找不到任何信息。 甚至搜索“area”也没有结果。

azure devops项目设置

1个回答

13

这里是您要查找的API调用:

https://learn.microsoft.com/en-us/rest/api/azure/devops/wit/classification%20nodes/get%20classification%20nodes?view=azure-devops-rest-5.1

GET https://dev.azure.com/{organization}/{project}/_apis/wit/classificationnodes?$depth={$depth}&api-version=5.0

这将提供给您根节点及其子节点,之后您可以查询单个子节点,我正在获取的子节点示例:

id            : 32
identifier    : GUID
name          : childname
structureType : area
hasChildren   : False
path          : \parent\Area\childname
url           : https://dev.azure.com/xxx/yyy/_apis/wit/classificationNodes/Are
                as/childname

C# API:

_destinationTfs = new VssConnection(new Uri(TfsUri), new VssBasicCredential(string.Empty, AccessToken));
_witClient = _destinationTfs.GetClient<WorkItemTrackingHttpClient>();

var areaPathNode = await _witClient.GetClassificationNodeAsync("PROJECT_NAME", TreeStructureGroup.Areas, depth: 1);
// areaPathNode.Children will contain all your area paths.

附注:它在API文档中被极好地隐藏了


1
谢谢!我会在周一测试并回复您。 - Ryan E.
1
尝试使用深度参数访问该URI时,我得到了hasChildren = true的结果,但实际上没有返回任何子项(例如没有“children”属性)。这可能是什么原因? - Farhad Abdolhosseini

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接