我正在尝试在TFS服务器上执行WIQL查询(在this示例之后)并获取包含tittle和其他字段的工作项。即使我在输出中定义了我想要的列,json也只返回id和url。
查询
Select [System.Title],
[System.Description],
[System.WorkItemType],[System.Id]
From WorkItems
Where [System.WorkItemType] = 'Task'
AND [State] <> 'Closed'
AND [State] <> 'Removed'
AND [System.AssignedTo] = @me
order by [Microsoft.VSTS.Common.Priority] asc, [System.CreatedDate] desc
Json回来了
{"queryType":"flat","queryResultType":"workItem","asOf":"2016-03-18T22:53:15.777Z","columns":[{"referenceName":"System.Title","name":"Title","url":"http://<my tfs server>/tfs/DefaultCollection/_apis/wit/fields/System.Title"},{"referenceName":"System.Description","name":"Description","url":"http://<my tfs server>/tfs/DefaultCollection/_apis/wit/fields/System.Description"},{"referenceName":"System.WorkItemType","name":"Work Item Type","url":"http://<my tfs server>/tfs/DefaultCollection/_apis/wit/fields/System.WorkItemType"},{"referenceName":"System.Id","name":"ID","url":"http://<my tfs server>/tfs/DefaultCollection/_apis/wit/fields/System.Id"}],"sortColumns":[{"field":{"referenceName":"Microsoft.VSTS.Common.Priority","name":"Priority","url":"http://<my tfs server>/tfs/DefaultCollection/_apis/wit/fields/Microsoft.VSTS.Common.Priority"},"descending":false},{"field":{"referenceName":"System.CreatedDate","name":"Created Date","url":"http://<my tfs server>/tfs/DefaultCollection/_apis/wit/fields/System.CreatedDate"},"descending":true}],"workItems":[{"id":6760,"url":"http://<my tfs server>/tfs/DefaultCollection/_apis/wit/workItems/6760"},{"id":6734,"url":"http://<my tfs server>/tfs/DefaultCollection/_apis/wit/workItems/6734"},{"id":6731,"url":"http://<my tfs server>/tfs/DefaultCollection/_apis/wit/workItems/6731"},{"id":6526,"url":"http://<my tfs server>/tfs/DefaultCollection/_apis/wit/workItems/6526"},{"id":6525,"url":"http://<my tfs server>/tfs/DefaultCollection/_apis/wit/workItems/6525"},{"id":6524,"url":"http://<my tfs server>/tfs/DefaultCollection/_apis/wit/workItems/6524"},{"id":6514,"url":"http://<my tfs server>/tfs/DefaultCollection/_apis/wit/workItems/6514"},{"id":6372,"url":"http://<my tfs server>/tfs/DefaultCollection/_apis/wit/workItems/6372"},{"id":6371,"url":"http://<my tfs server>/tfs/DefaultCollection/_apis/wit/workItems/6371"},{"id":6235,"url":"http://<my tfs server>/tfs/DefaultCollection/_apis/wit/workItems/6235"},{"id":6218,"url":"http://<my tfs server>/tfs/DefaultCollection/_apis/wit/workItems/6218"},{"id":6123,"url":"http://<my tfs server>/tfs/DefaultCollection/_apis/wit/workItems/6123"},{"id":6122,"url":"http://<my tfs server>/tfs/DefaultCollection/_apis/wit/workItems/6122"},{"id":6121,"url":"http://<my tfs server>/tfs/DefaultCollection/_apis/wit/workItems/6121"},{"id":6120,"url":"http://<my tfs server>/tfs/DefaultCollection/_apis/wit/workItems/6120"}]}
是否有任何标志我应该传递给查询,以便我可以在输出上获取这些字段?
答案 0 :(得分:7)
问题,从我可以看出的面值来看,是基于您引用的documentation page上提供的第一个 POST 示例。
查看json结果的内容,您会注意到以下json数组:
GET: https://fabrikam.visualstudio.com/DefaultCollection/_apis/wit/WorkItems?ids=300,299,298,17,16,15,14,9,8&fields=System.Id,System.Title,System.State&asOf=2014-12-29T20:49:34.617Z&api-version=1.0
在引用的documentation page中阅读以下内容:
“执行查询后,使用ID获取工作项 在查询结果响应中返回。你最多可以工作200个 一次一件物品。“
这意味着查询是一个两步过程
1。在第一次调用中检索工作项ID的列表。
2。通过拨打其他电话,检索第一个API呼叫中返回的工作项的更多详细信息。
200工作项限制的原因是有道理的,如果没有这样的限制,服务的响应性将受到负面影响。
然后,文档继续提供一个简明示例,从第一次api调用中获取返回的每个工作项ID(在 workItems 数组中)的数据。
下面的引用示例(来自同一个文档),请注意第一个查询中返回的ID将在此查询中使用:
{{1}}
底线:此时,没有标志强制api返回初始查询产生的所有工作项。