3
votes

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?

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

  • My Project: id=1234
    • Area 1: id=5678
      • Area 2: id= 9012

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

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.

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.

****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/[Project Name]/_apis/wit/classificationnodes/iterations/Release 1/Sprint 1 (etc.)

2
Why do you need the Area or Iteration ID? There is little use in the value...MrHinsh - Martin Hinshelwood
I am writing a tool that will need to back-query VSO from a work item service hook event. During the back call I need to be able to correlate the work item to an area and iteration to a mapped item in my database. Using a user-editable string (the path) as a means to identify a row in a database (the mapped area or iteration) seems unwise.Lane Goolsby
@LaneGoolsby It should be noted that the default iteration path, when none has been set (the project name is set there instead of /Release x/ Sprint Y) will give an error if accessed.Matthieu

2 Answers

4
votes

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.

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]

will give :

{"$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}

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

1
votes

There are three ways of identifying an Area (everything I post equally applies to Iterations also). The Path (string), the ID (int) and a Guid. each of them are used in different ways, and have different ramifications.

For example renaming an Area, does NOT change it's identity, therefore does not update a work item (the path returned for in a workitem is dynamic).

It is also possible to delete and recreate and identical path, but it will have a different ID.

The GUID is used primarily for the Excel Reports (such as are parent of the SharePoint portal)

Depending on how you want things to react determines the appropriate element to use.

I have not seen any issues with the ID that you mention, and if you could create a simple repro, I would be glad to look at it.

david(dot)corbin(at)dynconcepts(dot)com