如何使用Visual Studio REST API获取任务的用户故事

时间:2015-12-30 05:34:38

标签: api rest azure-devops workitem

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

我可以看到工作项的键是:

['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​​调用获取任务的父级(用户故事)或错误?

1 个答案:

答案 0 :(得分:4)

添加" expand = all"或" expand = relations"在您的请求中,url将显示链接的工作项和" System.LinkTypes.Hierarchy-Reverse" type指向Parent工作项。

示例:

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

enter image description here