azure-devopswiql

Get all items from iteration


I am trying to get all work items from a given iteration. I can filter on TaskType on other fields. But not iteration paths. Am I missing something here?

var body = "{\"query\": \"Select [System.Id], [System.Title], [System.State],[System.IterationPath] From WorkItems Where [System.IterationPath] = 'GAC\\Sprint 10'\"}";
var json = await HTTP.POST("https://xxx.visualstudio.com/_apis/wit/wiql?api-version=5.1", body, personalaccesstoken);
return JsonConvert.DeserializeObject<WorkItemIdList>(json);

Solution

  • I can filter on TaskType on other fields. But not iteration paths.

    Does below scripts is what you want?

    SELECT [System.Id], [System.Title], [System.WorkItemType], [System.State], [System.IterationPath] FROM workitems WHERE [System.IterationPath] = 'MerConsoleApp\Q4' AND [system.WorkItemType] = 'Bug'
    

    This WIQL can filter the Bug work items which located IterationPath is MerConsoleApp\Q4.

    In addition, I saw you are applying this WIQL from api. There's one thing you need pay attention, you may not get exactly work item data if you run WIQL from rest api.

    For example, since we specify fields in select, here we can get below data format while we run this WIQL from UI:

    enter image description here

    But for rest api, we defined and fixed the data structure of the work item as id + url. This means you can only get the satisfied work item id and its url, even if you has specified the [System.Id], [System.Title], [System.WorkItemType], [System.State] in it.