1
votes

Is there a bug in the REST api for TFS 2015 update 3 where it doesn't actually filter when when querying builds?

E.g. I run the below query and get 1000 results http://myservername:8080/tfs/DefaultCollection/myproject/_apis/build/builds

I run the following and get the same results http://myservername:8080/tfs/DefaultCollection/myproject/_apis/build/builds?definitionId=thisdefinitiondoesnotexist

And the same using top still returns 1000 results http://myservername:8080/tfs/DefaultCollection/myproject/_apis/build/builds?top=5

etc etc

It appears none of the filters are being applied - why is this?

1

1 Answers

2
votes

You need to run the query exactly following the syntax for the REST API. Otherwise it will automatically ignore the invalid parameters which behind the valid one, and just run the valid part.

Get a list of builds:

GET https://{instance}/DefaultCollection/{project}/_apis/build/builds?api-version={version}[&definitions={string}][&queues={string}][&buildNumber={string}][&type={string}][&minFinishTime={DateTime}][&maxFinishTime={DateTime}][&requestedFor={string}][&reasonFilter={string}][&statusFilter={string}][&tagFilters={string}][&propertyFilters={string}][&$top={int}][&continuationToken={string}]

The second query should be: (It's "definitions=" but not definitionId=)

GET http://myservername:8080/tfs/DefaultCollection/myproject/_apis/build/builds?definitions= {specify definition ID eg: 25,26,27}
It will response "count": 0, If the specified definition id does not exist.

The third query should be: (Add $ before "top" )

GET http://myservername:8080/tfs/DefaultCollection/myproject/_apis/build/builds?$top=5

Please see https://www.visualstudio.com/en-us/docs/integrate/api/build/builds for using the build REST API.