2

我正在使用 VSO(Visual Studio Online API),我正在使用这个查询:

{
"name": "All Workitems",
"wiql": "Select [System.Id], [System.Title], [System.State] From WorkItems order by [Microsoft.VSTS.Common.Priority] asc, [System.CreatedDate] desc"
}

好吧,我期待一个带有 ID 标题及其状态的工作项列表,但作为回应,我只得到它的 ID 和 URL。我应该使用什么查询?

回复:

{
    "queryType": "flat",
    "queryResultType": "workItem",
    "asOf": "2015-04-18T05:23:05.353Z",
    "columns": [
        {
            "referenceName": "System.Id",
            "name": "ID",
            "url": "https://sami1212.visualstudio.com/DefaultCollection/_apis/wit/fields/System.Id"
        },
        {
            "referenceName": "System.Title",
            "name": "Title",
            "url": "https://sami1212.visualstudio.com/DefaultCollection/_apis/wit/fields/System.Title"
        },
        {
            "referenceName": "System.State",
            "name": "State",
            "url": "https://sami1212.visualstudio.com/DefaultCollection/_apis/wit/fields/System.State"
        }
    ],
    "sortColumns": [
        {
            "field": {
                "referenceName": "Microsoft.VSTS.Common.Priority",
                "name": "Priority",
                "url": "https://sami1212.visualstudio.com/DefaultCollection/_apis/wit/fields/Microsoft.VSTS.Common.Priority"
            },
            "descending": false
        },
        {
            "field": {
                "referenceName": "System.CreatedDate",
                "name": "Created Date",
                "url": "https://sami1212.visualstudio.com/DefaultCollection/_apis/wit/fields/System.CreatedDate"
            },
            "descending": true
        }
    ],
    "workItems": [
        {
            "id": 7,
            "url": "https://sami1212.visualstudio.com/DefaultCollection/_apis/wit/workItems/7"
        },
        {
            "id": 6,
            "url": "https://sami1212.visualstudio.com/DefaultCollection/_apis/wit/workItems/6"
        },
        {
            "id": 5,
            "url": "https://sami1212.visualstudio.com/DefaultCollection/_apis/wit/workItems/5"
        },
        {
            "id": 4,
            "url": "https://sami1212.visualstudio.com/DefaultCollection/_apis/wit/workItems/4"
        },
        {
            "id": 3,
            "url": "https://sami1212.visualstudio.com/DefaultCollection/_apis/wit/workItems/3"
        },
        {
            "id": 2,
            "url": "https://sami1212.visualstudio.com/DefaultCollection/_apis/wit/workItems/2"
        },
        {
            "id": 1,
            "url": "https://sami1212.visualstudio.com/DefaultCollection/_apis/wit/workItems/1"
        }
    ]
}
4

2 回答 2

1

select [system.id] from workitems

然后当我得到结果时,我已经从 body -> field -> {id, url} [list] 中提取了所有 id

使用指定的 ID 列表,我已将 ID 列表发送到列出工作项端点

/workitems?ids=1,2, ...,您应该获得所有字段的所有工作项的结果..

有趣的是我们还可以在查询所有工作项时传递 where in (ids, ids2 ..) 子句。传入fields查询参数以过滤字段

于 2018-07-30T22:23:10.997 回答
0

我找到了解决这个问题的方法,我们可以简单地使用基于 ID 的 WorkItems 获取所有 webItems 的列表,我们将所有 ids 连接到 'ids' 查询参数中,这将返回所有选定 ids 的列表。例如

https://sami1212.visualstudio.com/DefaultCollection/_apis/wit/workitems?ids=1,2,3,4,5&api-version=1.0

于 2015-04-18T07:59:05.460 回答