gpt4 book ai didi

json - TFS API - WIQL - 查询只返回 id 和 url

转载 作者:行者123 更新时间:2023-12-04 14:41:51 26 4
gpt4 key购买 nike

我正在尝试在 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

杰森回来了
{"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 调用中返回的工作项的更多详细信息。

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

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

引用实例 (来自同一个文档)下面,请注意第一个查询中返回的 ID 将在此查询中使用:
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 返回初始查询产生的所有工作项。

关于json - TFS API - WIQL - 查询只返回 id 和 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36095663/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com