Search code examples
tfstfs-sdkchangeset

TFSAPI: Get previous version of a particular file


I have a program which can retrieve the files associated with a particular changeset. I need to compare this file to its previous version. I need to download the previous version of the file for this. Can someone help out with this?
Specific documentation/links are also appreciated.


Solution

  • You can refer to these API calls :

    You can compare two different versions of a file in Repos Files:

    enter image description here

    Then click in History to select a previous version:

    enter image description here

    As shown below, download the previous version of the file.

    enter image description here

    If you want to download files with rest api , you can refer to Items - Get .

    GET https://{instance}/{collection}/{project}/_apis/git/repositories/{repositoryId}/items?path={path}&scopePath={scopePath}&recursionLevel={recursionLevel}&includeContentMetadata={includeContentMetadata}&latestProcessedChange={latestProcessedChange}&download={download}&$format={$format}&versionDescriptor.versionOptions={versionDescriptor.versionOptions}&versionDescriptor.version={versionDescriptor.version}&versionDescriptor.versionType={versionDescriptor.versionType}&includeContent={includeContent}&resolveLfs={resolveLfs}&api-version=5.0