简体   繁体   English

Azure 运维专区 API

[英]Azure Devops Area API

I have found and successfully tested creating an Area for a project via the API.我发现并成功测试了通过 API 为项目创建区域。

POST https://dev.azure.com/fabrikam/Fabrikam-Fiber-Git/_apis/wit/classificationnodes/Areas?api-version=6.0 发布 https://dev.azure.com/fabrikam/Fabrikam-Fiber-Git/_apis/wit/classificationnodes/Areas?api-version=6.0

{ "name": "Web" } { “名称”:“网站” }

This as default creates an Area which is a Child of the Project Area.这默认创建一个区域,该区域是项目区域的子区域。

Project Name > Area Name项目名称 > 区域名称

I cannot see a method online of creating an Area via the API which is nested in multiple Areas (Child) so in the example below via API I want to create the "Child Area Name":我看不到通过嵌套在多个区域(子)中的 API 在线创建区域的方法,因此在下面的示例中,通过 API 我想创建“子区域名称”:

Project Name > Area 1 Name > Child Area Name项目名称 > 区域 1 名称 > 子区域名称

If anyone has done this before please could you provide any suggestions.如果有人以前这样做过,请您提供任何建议。

You should be able to add the path property to your POST request to create the area under a sub path:您应该能够将path属性添加到您的 POST 请求以在子路径下创建区域:

{ 
    "name": "Child Area Name",
    "path": "/area 1 name"
}

I remember having the same challenge sometimes ago, and eventually used a different API to create sub areas.我记得以前有时遇到过同样的挑战,最终使用了不同的 API 来创建子区域。 Here's what I did:这是我所做的:

Every Area path (and Iteration paths) has their unique IDs.每个区域路径(和迭代路径)都有其唯一的 ID。 You can retrieve all the area paths (or iteration paths) using the documented REST APIs .您可以使用记录的 REST API检索所有区域路径(或迭代路径)。 For example, you can use the following API to get all the area paths (you can decide the depth you want to query)比如你可以用下面的API来获取所有的区域路径(你可以自己决定要查询的深度)

https://dev.azure.com/{Org}/{project}/_apis/wit/classificationnodes/Areas?$depth={depth}&api-version=6.0

The above will give you a hierarchical structure for every nodes with their unique IDs.上面将为您提供每个具有唯一 ID 的节点的层次结构。 You need to grab the ID of the node/sub-node under which you want to create the next sub-area.您需要获取要在其下创建下一个子区域的节点/子节点的 ID。 Next you can create a payload like below:接下来,您可以创建如下所示的有效负载:

{ 
   operationData: "{ \"NodeName\": \"Sub-Area1\", \"ParentId\": \"Parent-GUID-You-Got-Earlier\" }", // Notice the value here is already serialized
   syncWorkItemTracking: false
}

Finally, post the above payload to the following URI:最后,将上述 payload 发布到以下 URI:

var uri = "https://dev.azure.com/{Org}/{projectId}/_admin/_Areas/CreateClassificationNode?useApiUrl=true&__v=5"

It will create the sub-area and will return the ID of the newly created sub-area Node info (including ID).它将创建子区域并返回新创建的子区域节点信息的ID(包括ID)。

Hope this help you get going.希望这能帮助你开始。

PS: If anybody could shared who figured out how to achieve the same using the standard/documented API please share. PS:如果有人可以分享谁知道如何使用标准/记录的 API实现相同的目标,请分享。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM