TFS API - WIQL - 仅查询 returns id 和 url

TFS API - WIQL - Query only returns id and url

我正在尝试在 TFS 服务器上执行 WIQL 查询(按照 this 示例)并获取带有标题和其他字段的工作项。即使我在输出中定义了我想要的列,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"}]}

我是否应该将任何标志传递给查询以便在输出中获取这些字段?

据我所知,这个问题是基于您引用的 documentation page 中提供的第一个 POST 示例。

查看 json 结果的内容,您会注意到以下 json 数组:

"workItems":[
{"id":7331, 
"url":"https://<hostname>/tfs/<collection>/_apis/wit/workItems/7331"}, ... etc.

继续阅读 documentation page 引用如下:

"After executing your query, get the work items using the IDs that are returned in the query results response. You can get up to 200 work items at a time."

这意味着查询是一个两步过程

1. 在第一次调用中检索工作项 ID 的列表。

2. 通过进行额外的调用检索在第一个 api 调用中 return 工作项的更多详细信息。

200 个工作项限制的原因是有道理的,如果没有这样的限制,服务的响应能力将受到负面影响。

文档然后继续提供一个简明示例,从第一个 returned(在 workItems 数组中)获取每个工作项 ID 的数据api 调用。

下面的参考示例(来自同一文档),请注意第一个查询中的 ID returned 将用于此查询:

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

底线: 此时,没有标志强制 api 到 return 初始查询产生的所有工作项。