Unable to download a file from Azure Repos using azure devops api python

Viewed 37

I am trying to write a script to download a single file from azure repos using python. I am using the official Microsoft library https://github.com/microsoft/azure-devops-python-api

from azure.devops.connection import Connection
from msrest.authentication import BasicAuthentication

personal_access_token = "MY_PAT"
organization_url = "MY_ORGANIZATION_URL"
repo_id = "MY_REPOSITORY_ID"
file_path = "/FOLDER_NAME/FILE_NAME"
credentials = BasicAuthentication('', personal_access_token)
connection = Connection(base_url=organization_url, creds=credentials)
git_client = connection.clients.get_git_client()
file_content = git_client.get_item_content(repo_id,path=file_path,download=True,include_content=True)
print(file_content)

The response is a generator object

<generator object RequestsClientResponse.stream_download at 0x000002517CCC8900>

But the file is not actually downloading. Any idea.

0 Answers
Related