如何从Azure DevOps Services REST API获得可用的区域路径?

问题描述 投票:0回答:1

我找不到如何从API检索区域路径。我能够到达迭代路径而不是区域路径。

我在技术上使用c#包装器

我试过了

  • ProjectHttpClient.GetProject()
  • ProjectHttpClient.GetProjectPropertiesAsync();
  • WorkItemTrackingHttpClient.GetFieldAsync( “System.AreaPath”);
  • WorkItemTrackingHttpClient.GetWorkItemTypeFieldWithReferencesAsync();
  • 因为我从那里得到了迭代,所以我也查看了WorkHttpClient。
  • 我查看了文档但找不到任何内容。即使搜索“区域”也没有结果。

azure devops project settings

azure-devops azure-devops-rest-api
1个回答
2
投票

以下是您要查找的API调用:

https://docs.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.

PS。它非常隐藏在API文档中

© www.soinside.com 2019 - 2024. All rights reserved.