0

I'm trying to download a file with the Azure Devops Rest API using Powershell's Invoke-RestMethod. It always seems to download from the main branch and ignores my branch specification

The urls I'm using are

invoke-restmethod -uri "https://dev.azure.com/company/xxx/_apis/git/repositories/xxx/items?path=%2Fpom.xml&commitOrBranch=main&api-version=6.0" -Method Get -ContentType "application/text" -Headers $headers 

and

invoke-restmethod -uri "https://dev.azure.com/company/xxx/_apis/git/repositories/xxx/items?path=%2Fpom.xml&commitOrBranch=branchName&api-version=6.0" -Method Get -ContentType "application/text" -Headers $headers 

How do I specify the branch? The documentation doesn't provide any details

2

1 Answer 1

2

You could try the below commandlet.

Just modified the below based on the question to download a pom.xml from the <BranchName>

invoke-restmethod -uri "https://dev.azure.com/company/xxx/_apis/git/repositories/xxx/items/pom.xml?versionType=Branch&version=<BranchName>" -Method Get -ContentType "application/text" -Headers $headers 
Sign up to request clarification or add additional context in comments.

1 Comment

Yes, I had already figured this out based on additional research. I don't understand all the inconsistent documentation on this api, but this was the solution

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.