azure-devops-python-api icon indicating copy to clipboard operation
azure-devops-python-api copied to clipboard

How to download a file or the whole repository as a .zip file in SDK?

Open dylanwa opened this issue 5 years ago • 1 comments

I can successfully download a file or folder if sending the request through a web browser.

  • Download the repostiroy as a .zip file https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/items?path=/&$format=zip&download=true

  • Download a file https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/items?path=/folder1/folder2/file3.txt&download=true

But using the SDK, nothing happened though get_item returned the right object. item = git_client.get_item(repo.id, path="/folder1/folder2/file3.txt", download=True)

dylanwa avatar May 03 '21 04:05 dylanwa

file_content=git_client.get_item_content(repository_id='-----', path=ktm.md', download=True,include_content=True)

with open('output.md', 'wb') as f: for x in file_content: f.write(x)

jmandivarapu avatar Jul 22 '23 12:07 jmandivarapu