使用REST API获取Azure DevOps中的所有组织 [英] Get all organizations in Azure DevOps using REST API

查看:70
本文介绍了使用REST API获取Azure DevOps中的所有组织的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试检索帐户中的所有组织,但是在文档中,API调用中始终需要一个组织.

I am trying to retrieve all the organizations in my account but in the documentation an organization is always required in the API call.

https://dev.azure.com/{organization}/_apis/...

推荐答案

如果加载当前登录页面,它将显示与您的帐户相关联的所有组织.我以为它必须以某种方式获取该信息.我捕获了网络流量,并相信您可以使用系统API调用获得所需的数据.但是,它可能会更改或可能不受支持,恕不另行通知,因此请自行决定使用.

If you load the current landing page, it displays all your organizations tied to your account. I assumed it had to get that information some way. I captured the network traffic and I believe you could get to the data you want using a system API call. However, it might change or might become unsupported without notice, so use at your own discretion.

您可以使用此API获取所需的信息:

You can get the information you want using this API:

Post https://dev.azure.com/{organization1}/_apis/Contribution/HierarchyQuery?api-version=5.0-preview.1

身体:

{
    "contributionIds": ["ms.vss-features.my-organizations-data-provider"],
    "dataProviderContext":
        {
            "properties":{}
        }
}

回复:

{
    "dataProviderSharedData": {},
    "dataProviders": {
        "ms.vss-web.component-data": {},
        "ms.vss-web.shared-data": null,
        "ms.vss-features.my-organizations-data-provider": {
            "organizations": [
                {
                    "id": "{redacted id}",
                    "name": "{organization1}",
                    "url": "https://{organization1}.visualstudio.com/"
                },
                {
                    "id": "{redacted id}",
                    "name": "{organization2}",
                    "url": "https://dev.azure.com/{organization2}/"
                }
            ],
            "createNewOrgUrl": "https://app.vsaex.visualstudio.com/go/signup?account=true"
        }
    } }

这篇关于使用REST API获取Azure DevOps中的所有组织的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆