【问题标题】:How do you get available Area Paths from Azure DevOps Services REST API?如何从 Azure DevOps Services REST API 获取可用的区域路径?
【发布时间】:2019-09-03 16:50:29
【问题描述】:

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

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

我试过了

  • ProjectHttpClient.GetProject()
  • ProjectHttpClient.GetProjectPropertiesAsync();
  • WorkItemTrackingHttpClient.GetFieldAsync("System.AreaPath");
  • WorkItemTrackingHttpClient.GetWorkItemTypeFieldWithReferencesAsync();
  • 自从我从那里获得迭代后,我也查看了 WorkHttpClient。
  • 我浏览了文档,但找不到任何东西。即使搜索“区域”也不会返回任何结果。

【问题讨论】:

    标签: azure-devops azure-devops-rest-api


    【解决方案1】:

    以下是您要查找的 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 文档中隐藏得非常好

    【讨论】:

    • 谢谢!我会在星期一测试这个并回复你。
    • 当尝试该 uri 时,即使使用深度参数,我也会得到 hasChildren = true,但实际上没有返回子级(例如,没有“children”属性)。什么可能导致这种情况?
    猜你喜欢
    • 1970-01-01
    • 2020-02-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-05
    • 1970-01-01
    • 2022-09-23
    • 2017-01-02
    相关资源
    最近更新 更多