1

I have been searching the Azure DevOps API documentation to find out how to get the owner of an organization via the API. I have been able to get a list of groups and a list of users, among other things, but not the organization. So far, I am using SoapUI to test my calls. Later, I'll build a C# project.

Related information:

Super Jade
  • 5,609
  • 7
  • 39
  • 61

1 Answers1

4

I was managed to find the REST API with the help of the DevOps portal. Navigate to dev.azure.com with the administrator credentials. If you navigate to overview and keep the network traffic opened, You can see the request ,

https://dev.azure.com/{yourOrganization}/_apis/Contribution/HierarchyQuery

which gives a response as,

{
  "dataProviderSharedData": {},
  "dataProviders": {
    "ms.vss-web.component-data": {},
    "ms.vss-web.shared-data": null,
    "ms.vss-admin-web.organization-admin-overview-data-provider": {
      "id": "cf9a37c1-7c97-4018-8530-962f45b30999",
      "name": "ngColombo",
      "timeZone": {
        "displayName": "UTC",
        "id": "UTC"
      },
      "url": "https://dev.azure.com/ngColombo/",
      "description": "",
      "privacyUrl": "",
      "region": "East Asia",
      "hasModifyPermissions": true
    }
  }

}

you can see ms.vss-admin-web.organization-admin-overview-data-provider which will give the owner of the organization.

enter image description here

SAMPLE CODE:

getOrganisations () {
    const body = {
      'contributionIds': ['ms.vss-features.my-organizations-data-provider'],
      'dataProviderContext': {
        'properties': {}
      }
    }

    const url = 'https://dev.azure.com/Aevitae/_apis/Contribution/HierarchyQuery?api-version=5.0-preview.1'
    return axios.post(url, body, this.options)
  }
Sajeetharan
  • 216,225
  • 63
  • 350
  • 396
  • Plugging a `GET https://dev.azure.com/{org name}/_apis/Contribution/HierarchyQuery` call into SoapUI with my auth in the header returns `HTTP/1.1 405 Method Not Allowed`. I'll work on this... – Super Jade Dec 17 '19 at 05:13
  • May be it needs special role :P. I tried to hack something – Sajeetharan Dec 17 '19 at 05:16
  • I don't know what a special role is. I've gotten through a couple more error messages. My current error message: `"Value cannot be null.\r\nParameter name: query"` – Super Jade Dec 17 '19 at 05:22
  • Hmm... Adding the body to my POST request returns a `200 OK` that gives all the orgs in my account like [this post](https://stackoverflow.com/questions/54762368/get-all-organizations-in-azure-devops-using-rest-api) – Super Jade Dec 17 '19 at 05:36
  • 2
    Got it! I edited the POST body to `{ 'contributionIds': ['ms.vss-admin-web.organization-admin-overview-delay-load-data-provider'], 'dataProviderContext': { 'properties': {} } }` and the URL to `https://dev.azure.com/{org name}/_apis/Contribution/HierarchyQuery?api-version=5.1-preview.1` It returns the org owner along with plenty of other information. :-) – Super Jade Dec 17 '19 at 05:51
  • 1
    The part that helped the most was your image of how you viewed the network traffic. I was able to do the same thing, and then I constructed the query from there. :-) – Super Jade Dec 17 '19 at 06:13