【问题标题】:AttributeError: 'list' object has no attribute 'value' - Python API for Azure DevOpsAttributeError: 'list' 对象没有属性 'value' - Azure DevOps 的 Python API
【发布时间】:2020-03-03 20:38:10
【问题描述】:

我正在尝试使用来自https://github.com/Microsoft/azure-devops-python-api 的 Python API 但得到类似“AttributeError:'list'对象没有属性'value'”的错误

下面是sn-p

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 = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
organization_url = 'xxxxxxxxxxxxxxxxxxxxxx'

# 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

【问题讨论】:

  • 好几天没有收到您的回复,能否分享一下您对此问题的最新信息?如果您有任何疑问,请随时在此处分享。

标签: python azure api azure-devops devops


【解决方案1】:

该错误意味着您提供的凭据没有处于活动状态的项目,或者您返回的是一个空字典。

您可以尝试在循环之前打印它,您将能够看到您可能会得到一个空字典或没有名为 value 的键的字典。

print(get_projects_response)#update the output of this to your question to get a better clarity 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-12-04
    • 2023-02-15
    • 2013-07-19
    • 1970-01-01
    • 1970-01-01
    • 2023-04-09
    • 2014-09-08
    相关资源
    最近更新 更多