1

I'm part of more than one organization in Azure DevOps. It's easy to navigate between organizations in Web interface. But I'm looking to get the list of my organization in C#.

I can't find anything related in these links and in Google:

https://learn.microsoft.com/en-us/rest/api/azure/devops/?view=azure-devops-server-rest-5.0

https://github.com/microsoft/azure-devops-dotnet-samples

https://www.dotnetcurry.com/devops/1485/using-rest-api-azure-devops

2 Answers2

2

You're looking for the accounts API.

GET https://app.vssps.visualstudio.com/_apis/accounts?api-version=5.1
Daniel Mann
  • 57,011
  • 13
  • 100
  • 120
  • Any word on how to get the `properties` to expand, or what values to expect in that property? The documentation is pretty scant. – Josh Gust Jul 20 '19 at 17:55
  • Where should I get my `memberId` from? – mohammad rostami siahgeli Jul 21 '19 at 05:38
  • @mohammadrostamisiahgeli Member ID is optional. – Daniel Mann Jul 21 '19 at 13:16
  • No, it's not optional. This is the error I get: `{ $id: "1", innerException: null, message: "Necessary parameters ownerId or memberId were not provided in the request.", typeName: "Microsoft.VisualStudio.Services.Account.AccountException, Microsoft.VisualStudio.Services.WebApi", typeKey: "AccountException", errorCode: 0, eventId: 4236 }` – mohammad rostami siahgeli Jul 22 '19 at 11:40
  • @JoshGust i was wondering the same, years later and still the documentation on it is really bad. Was trying to implement the call with .NET Client libraries but cant find the accounts class anywhere. Also for getting your memberId go to the profile operation, see https://stackoverflow.com/a/61299987/5294174 – Mimic01 Dec 01 '22 at 17:08
1

Create PAT:

enter image description here

Get member ID: https://learn.microsoft.com/en-us/rest/api/azure/devops/memberentitlementmanagement/user%20entitlements/get%20user%20entitlements?view=azure-devops-rest-5.1

enter image description here

Copy Id of a user from result and call REST API to get organizations:

enter image description here

starian chen-MSFT
  • 33,174
  • 2
  • 29
  • 53