2015-12-30 87 views
1

我正尝试使用Visual Studio的API将Visual Studio Online团队的工作项信息收集到Excel文档中。通过使用API​​调用来提取其json字段,我可以获取工作项目的信息以及每个项目是用户故事,任务还是Bug。但是,我无法弄清楚如何获取任务或Bug的“父”用户故事。例如。任务将在我的工作板上的用户故事部分内,但在工作项目的可能的json键中没有看到与该故事对应的任何字段。如何使用Visual Studio REST API获取用户任务的故事

,我可以看到一个工作项目的关键是这些:

['System.AuthorizedDate', 
'System.WorkItemType', 
'System.Title', 
'System.IterationLevel1', 
'System.IterationLevel2', 
'System.History', 
'System.AreaId', 
'System.NodeName', 
'Microsoft.VSTS.Common.ActivatedDate', 
'System.IterationId', 
'System.IterationPath', 
'System.PersonId', 
'System.AssignedTo', 
'System.AuthorizedAs', 
'System.Id', 
'System.Reason', 
'System.CreatedBy', 
'Microsoft.VSTS.Common.StateChangeDate', 
'Microsoft.VSTS.Common.Priority', 
'System.Watermark', 
'Microsoft.VSTS.Common.ActivatedBy', 
'System.AreaPath', 
'System.State', 
'System.ChangedDate', 
'System.AreaLevel1', 
'System.CreatedDate', 
'System.TeamProject', 
'System.Rev', 
'System.ChangedBy', 
'System.RevisedDate'] 

它们的值没有对应任何匹配的用户故事的文本或提供了一个网址给用户故事的JSON。

有谁知道如何使用API​​调用获取任务的父代(用户故事)或错误?

回答

4

在请求URL中添加“expand = all”或“expand = relations”将显示链接的工作项目,“System.LinkTypes.Hierarchy-Reverse”类型指向父工作项目。

例子:

https://xxxxx.visualstudio.com/defaultcollection/_apis/wit/workitems?ids=47&$expand=relations&api-version=1.0 

enter image description here

+0

非常感谢您!你不知道我一直在寻找多长时间的网址来扩展多个工作项目。 :) 你知道'System.LinkTypes.Hierarchy-Reverse'和'System.LinkTypes.Related'之间有什么区别吗?他们都出现在我的“关系”下,但他们是针对不同的卡片(实际上,“相关”是与原始卡片相同的网址,我不明白VSO为什么拥有所有这些自我指涉循环)。 – Elliptica

+0

Hierarchy-Reverse是父类(来自父 - 子),从头部开始。相关的只是相关的链接类型。关系中显示任何链接。 VSO(和TFS)一直有很长的链接类型列表,每个链接类型都有自己的用途,并且通常与特定的功能相关联。大多数解释在这里:https://msdn.microsoft.com/en-us/library/dd293527.aspx – jessehouwing

相关问题