2

I'm trying to crawl the changesets from a TFS 2015 server via the API. I'm using the $top and $skip parameters to do the paging as documented. However some odd behaviours are occurring:

  • Requesting 255 items returns all 255. Requesting 256 and above only returns 132.
  • The Link HTTP header is not included in the response for the second page - preventing automatic crawling.
  • Manually incrementing the $skip parameter in a browser returns zero items.

Is it possible to page items via the API or does TFS place limitations to prevent it?

Laurel
  • 5,965
  • 14
  • 31
  • 57
Talon
  • 143
  • 1
  • 7

1 Answers1

2

API can only return 256 changesets. So to get all of them you need to:

1) get first 256 changesets (I used orderby in case of different order in responses):

_apis/tfvc/changesets?$top=256&orderby=id desc&searchCriteria.itemPath=<your_path>&api-version=1.0

2) if you have more then 0 items in response get last value of changesetNumber from response. If 0 - you got all changesets.

3) get next 256 items starting from changesetNumber:

 _apis/tfvc/changesets?searchCriteria.toId=<changesetNumber>&$top=256&orderby=id desc&searchCriteria.itemPath=<your_path>&api-version=1.0

You need to skip first changeset (you already have this value) in response.

4) go to Step 2

Vitaly
  • 61
  • 4