title: How to download a file in a branch from a Git repo using Azure DevOps REST Api?
body: <p>For a file in the master branch I can use the following URL - <code>http://tfsserver:8080/tfs/DefaultCollection/TFSProject/_apis/git/repositories/GitRepo/items?path=FilePath&amp;api-version=4.1</code></p>
  
  <p>But what if I need to download a file from the branch?</p>
  
  <p>P.S.</p>
  
  <p>I know perfectly well that I can clone a git repository. I need REST API specifically.</p>
  
  <p><strong>EDIT 1</strong></p>
  
  <p>So, I tried the following code:</p>
  
  <pre><code>$Url = "http://tfsserver:8080/tfs/DefaultCollection/code/_apis/git/repositories/xyz/itemsbatch?api-version=4.1"
  $Body = @"
  {
      "itemDescriptors": [
      {
          "path": "/Bootstrap.ps1",
          "version": "shelve/vsts",
          "versionType": "branch"
      }]
  }
  "@
  Invoke-RestMethod -UseDefaultCredentials -Uri $Url -OutFile $PSScriptRoot\AutomationBootstrapImpl.ps1 -Method Post -ContentType "application/json" -Body $Body
  </code></pre>
  
  <p>It succeeds, but the generated file is not exactly what I expected:</p>
  
  <pre><code>{"count":1,"value":[[{"objectId":"ceb9d83e971abdd3326d67e25b20c2cb1b4943e2","gitObjectType":"blob","commitId":"d4a039914002613e775f6274aee6489b244a42a7","path":"/bootstrap.ps1","url":"http://tfsserver:8080/tfs/DefaultCollection/code/_apis/git/repositories/xyz/items/bootstrap.ps1?versionType=Branch&amp;version=shelve%2Fvsts&amp;versionOptions=None"}]]}
  </code></pre>
  
  <p>However, it gives the URL I can use to get the file from branch - <code>http://tfsserver:8080/tfs/DefaultCollection/code/_apis/git/repositories/xyz/items/bootstrap.ps1?versionType=Branch&amp;version=shelve%2Fvsts&amp;versionOptions=None</code></p>
  
  <p>So, here we go:</p>
  
  <pre><code>$Url = "http://tfsserver:8080/tfs/DefaultCollection/code/_apis/git/repositories/xyz/items/bootstrap.ps1?versionType=Branch&amp;version=shelve/vsts"
  Invoke-RestMethod -UseDefaultCredentials -Uri $Url -OutFile $PSScriptRoot\AutomationBootstrapImpl.ps1
  </code></pre>
  
  <p>And it works as expected. But I still do not know what is the name of this API method?</p>