Visual Studio REST API 迭代和区域 ID [英] Visual Studio REST API Iteration and Area ID's

查看:11
本文介绍了Visual Studio REST API 迭代和区域 ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 VSO REST API,并且对如何分配迭代和区域 ID 有疑问.具体来说,为什么当我将工作项分配给根迭代或区域时,查询分类节点时没有返回为WIT返回的ID?

I am working with the VSO REST API and have a question on how Iteration and Area ID's are assigned. Specifically, why is it when I assign a work item to the root Iteration or Area the ID that is returned for the WIT is not returned when I query the classification nodes?

例如,假设我在查询/DefaultCollection/my project/_apis/wit/classificationnodes?$depth=2

For example, imagine I have this hierarchy when I query /DefaultCollection/my project/_apis/wit/classificationnodes?$depth=2

  • 我的项目:id=1234
    • 区域 1:id=5678
      • 区域 2:id= 9012

      然后我使用/DefaultCollection/_apis/wit/workItems/1?$expand=all

      And I then query for a work item using /DefaultCollection/_apis/wit/workItems/1?$expand=all

      如果工作项位于区域 1 或区域 2 中,则 System.AreaId 字段符合预期(分别为 5678 和 9012).但是,如果我将工作项分配给我的项目,则 System.AreaID 是在查询所有分类节点时不包括的某个值.ID 之间似乎存在某种关系,因为它们是串行的(例如,分类节点查询返回的 ID 为区域 1232,迭代为 1233),但我似乎找不到查询到的方法获取工作项查询返回的实际 ID.

      If the work item is in Area 1 or Area 2, the System.AreaId field is as expected (5678 and 9012, respectively). However, if I assign the work item to My Project, the System.AreaID is some value that is not included when I query for all classification nodes. There appears to be some kind of relationship between the ID's as they are serial (e.g. the ID returned by the classification node query is 1232 for the area and 1233 for the iteration), but I can't seem to find a way to query to get the actual ID returned by the work item query.

      事实上,不仅当我查询所有分类节点时不存在工作项返回的ID,如果我将工作项同时分配给根迭代和区域,则两个字段返回的ID是相同的值不包括在分类节点查询中.

      In fact, not only is the ID returned for a work item not present when I query for all classification nodes, if I assign the work item to both the root iteration and area, the ID returned for both fields is the same value that is not included in the classification node query.

      我需要的是一种查看工作项并找出它所属的区域和迭代的方法.我可能可以对返回的路径字段字符串做一些事情,但这似乎很容易出错,因为用户可以更改它们.

      What I need is a way to look at a work item and figure out the area and iteration it belongs to. I could probably do something with the path field strings that are returned, but that seems error prone since users can change them.

      ****编辑****以上似乎是 REST API 中的一个错误,但对于遇到这篇文章的任何人,都有一种方法可以通过路径字符串获取可用的迭代 ID.像这样构建您的 REST 调用:

      ****Edit**** The above appears to be a bug in the REST API, but for anyone who comes across this post there is a way to get a usable iteration ID by the path string. Structure your REST call like so:

      /DefaultCollection/[项目名称]/_apis/wit/classificationnodes/iterations/Release 1/Sprint 1 (etc.)

      /DefaultCollection/[Project Name]/_apis/wit/classificationnodes/iterations/Release 1/Sprint 1 (etc.)

      推荐答案

      我从来没有用 ID 做过这个.我只使用路径.在分类服务中,您可以很容易地通过路径获取节点.

      I have never done this with ID. I only use the path. In the classification service you can get the node by path easily enough.

      例如,使用 REST API - 您可以访问此 url 以获取有关特定迭代的数据:

      For example, using the REST API - you can access this url to get the data about a specific iteration:

      /DefaultCollection/[Project Name]/_apis/wit/classificationnodes/iterations/[Release X]/[Sprint Y]
      

      请注意,尝试访问默认迭代路径(项目名称而不是特定迭代)将返回错误:

      Note that trying to access the default iteration path (the project name instead of a specific iteration) will return an error:

      /DefaultCollection/[Project Name]/_apis/wit/classificationnodes/iterations/[Project Name]
      

      会给:

      {"$id":"1","innerException":null,"message":"VS402485: The node name is not recognized: [Project Name]","typeName":"Microsoft.TeamFoundation.WorkItemTracking.Server.Metadata.WorkItemTrackingTreeNodeNotFoundException, Microsoft.TeamFoundation.WorkItemTracking.Server","typeKey":"WorkItemTrackingTreeNodeNotFoundException","errorCode":0,"eventId":3200}
      

      因此,如果您进行批处理工作,则必须在查询 api 之前对其进行过滤.

      So if you do batch work, you have to filter those before querying the api.

      这篇关于Visual Studio REST API 迭代和区域 ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆