Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TFS API - WIQL - Query only returns id and url

I am trying to execute a WIQL query on TFS server (following this example) and get work items with the tittle and other fields. Even though I define the columns I want on the output, the json returned only with id and url.

Query

 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 returned

{"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"}]}

Is there any flag that I should pass to the query so I can get those fields on the ouput?

like image 577
rbianchi Avatar asked Mar 18 '16 23:03

rbianchi


1 Answers

The question, from what I can tell at face value, is based on the first POST example provided on the documentation page you referenced.

Looking at the contents of your json result you'll notice the following json array:

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

Reading on in the documentation page referenced the following is stated:

"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."

This means the query is a two step process

1. retrieve a list of work item id's in the first call.

2. retrieve more detail on the workitems returned in the first api call by making additional calls.

The reason for the 200 work item limit makes sense, the responsiveness of the service would be negatively impacted if there was no such limit.

The documentation then continues on to provide a concise example of getting data for each of the work item IDs returned (in the workItems array) from the first api invocation.

Referenced example (from the same doc) below, note that the ID's returned in the first query would be used in this query:

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

bottom line: At this point, there is no flag that forces the api to return all workitems resulting from the initial query.

like image 153
Elmar Avatar answered Sep 21 '22 03:09

Elmar