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

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

问题描述

我正在使用VSO REST API,并且对如何分配迭代和区域ID有疑问.具体来说,为什么当我将工作项分配给根Iteration或Area时,为什么我在查询分类节点时未返回为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
      • My Project: id=1234
        • Area 1: id=5678
          • Area 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/版本1/冲刺1(等)

          /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天全站免登陆