如何使用 Azure DevOps Python API 获取项目列表?
How do I get the list of projects using the Azure DevOps Python API?
我正在尝试列出来自 Azure devops 组织的项目列表。我正在使用 python,在 https://github.com/Microsoft/azure-devops-python-api
之后
这是我的脚本
from vsts.vss_connection import VssConnection
from msrest.authentication import BasicAuthentication
import pprint
token = "Access token"
Azure_url = "https://dev.azure.com/{organization}/"
Credentials = BasicAuthentication("", token)
connection = VssConnection(base_url=Azure_url, creds=Credentials)
core_client = connection.get_client('vsts.core.v4_0.core_client.CoreClient')
projects = core_client.get_projects()
我得到的输出
[<vsts.core.v4_0.models.team_project_reference.TeamProjectReference object at 00txgccbdffff>]
他们是获取 Json 格式的项目列表的方法吗?
Is their a way to get list of projects in Json format.
是的,请尝试使用以下代码将项目列表转换为 json 字符串。
import json
json_string = json.dumps([ob.__dict__ for ob in projects])
pprint.pprint(json_string)
我正在尝试列出来自 Azure devops 组织的项目列表。我正在使用 python,在 https://github.com/Microsoft/azure-devops-python-api
之后这是我的脚本
from vsts.vss_connection import VssConnection
from msrest.authentication import BasicAuthentication
import pprint
token = "Access token"
Azure_url = "https://dev.azure.com/{organization}/"
Credentials = BasicAuthentication("", token)
connection = VssConnection(base_url=Azure_url, creds=Credentials)
core_client = connection.get_client('vsts.core.v4_0.core_client.CoreClient')
projects = core_client.get_projects()
我得到的输出
[<vsts.core.v4_0.models.team_project_reference.TeamProjectReference object at 00txgccbdffff>]
他们是获取 Json 格式的项目列表的方法吗?
Is their a way to get list of projects in Json format.
是的,请尝试使用以下代码将项目列表转换为 json 字符串。
import json
json_string = json.dumps([ob.__dict__ for ob in projects])
pprint.pprint(json_string)