Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in running the code give in ReadMe file. #494

Open
Ddhruv-IOT opened this issue Apr 15, 2024 · 0 comments
Open

Error in running the code give in ReadMe file. #494

Ddhruv-IOT opened this issue Apr 15, 2024 · 0 comments

Comments

@Ddhruv-IOT
Copy link

Steps to re-produce:

provide the PAT and org name and execute the code.

The code used from the README File:

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

# Fill in with your personal access token and org URL
personal_access_token = 'YOURPAT'
organization_url = 'https://dev.azure.com/YOURORG'

# Create a connection to the org
credentials = BasicAuthentication('', personal_access_token)
connection = Connection(base_url=organization_url, creds=credentials)

# Get a client (the "core" client provides access to projects, teams, etc)
core_client = connection.clients.get_core_client()

# Get the first page of projects
get_projects_response = core_client.get_projects()
index = 0
while get_projects_response is not None:
    for project in get_projects_response.value:
        pprint.pprint("[" + str(index) + "] " + project.name)
        index += 1
    if get_projects_response.continuation_token is not None and get_projects_response.continuation_token != "":
        # Get the next page of projects
        get_projects_response = core_client.get_projects(continuation_token=get_projects_response.continuation_token)
    else:
        # All projects have been retrieved
        get_projects_response = None

The Error I got:

project in get_projects_response.value:
AttributeError: 'list' object has no attribute 'value'

Suggested fix in code:

# Get a client (the "core" client provides access to projects, teams, etc)
core_client = connection.clients.get_core_client()

# Get the first page of projects
get_projects_response = core_client.get_projects()

index = 0
for project in get_projects_response:
    pprint.pprint("[" + str(index) + "] " + project.name)
    index += 1

The output:

'[0] Interns_round'
'[1] Smart_Iot_Lab'

Ddhruv-IOT added a commit to Ddhruv-IOT/azure-devops-python-api that referenced this issue Apr 15, 2024
The example code was not running. Modified the code to fix the error faced previously

More reference here:  microsoft#494
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant