Skip to content

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

Description

@Ddhruv-IOT

Steps to re-produce:

provide the PAT and org name and execute the code.

The code used from the README File:

fromazure.devops.connectionimportConnectionfrommsrest.authenticationimportBasicAuthenticationimportpprint# Fill in with your personal access token and org URLpersonal_access_token='YOURPAT'organization_url='https://dev.azure.com/YOURORG'# Create a connection to the orgcredentials=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 projectsget_projects_response=core_client.get_projects()
index=0whileget_projects_responseisnotNone:
forprojectinget_projects_response.value:
pprint.pprint("["+str(index) +"] "+project.name)
index+=1ifget_projects_response.continuation_tokenisnotNoneandget_projects_response.continuation_token!="":
# Get the next page of projectsget_projects_response=core_client.get_projects(continuation_token=get_projects_response.continuation_token)
else:
# All projects have been retrievedget_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 projectsget_projects_response=core_client.get_projects()
index=0forprojectinget_projects_response:
pprint.pprint("["+str(index) +"] "+project.name)
index+=1

The output:

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions