查询仅返回 ID 和 URL of workItems list 不返回 title

Query only returning ID and URL of workItems list not returning title

我正在使用 VSO(Visual Studio 在线 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"
        }
    ]
}

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

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

select [system.id] from workitems

然后当我得到结果时,我从正文中提取了所有 id -> 字段 -> {id, url} [list]

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

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

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