Why does calling the "Tenants - List" azure api provide other json output than the "Try it" feature?

Martin D 61 Reputation points
2020-10-27T12:51:54.947+00:00

When I call the latest official version (2020-01-01) of the list tenants api (management.azure.com/tenants) I don't see the same properties in the json response that I see when using the "Try it" feature on the "Tenants - List" page in the online Azure REST documentation.

The response that I get, when calling the api in my c# code, only contains the "id", "tenantId" and "tenantCategory" properties. So the cool stuff like countryCode, domains, displayName, etc. are missing. I was using an older api version before which only included the "id" and "tenantId" properties so I do see the additional "tenantCategory" property at least.

When calling the 2020-01-01 version of the subscriptions list API in my code I do get all the same properties that I see when I use the "Try it" feature.

So my first question is if I'm doing something wrong, if this might be a bug and if anyone else is experiencing this behaviour?

Also, when I specify an invalid version in the "Try it" feature I see that there seems to be even later versions of the list tenants api available; namely 2020-07-01, 2020-06-01 and 2020-05-01. However, there is no information about them when I call the providers api (namespace Microsoft.Resources, resourceType tenants) as the 2020-01-01 version is the first one listed in the apiVersions array.

So my second question is if there is a way to get those later versions programatically? I can't seem to find any mention of them online or in any Githud repo. I also only get a web exception 400 bad request when I use an invalid version in my api calls so the json response in the "Try it" feature seems to originate from somewhere else completely.

Thanks in advance for any help wrapping my head around this stuff.

Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
21,365 questions
0 comments No comments
{count} votes

Accepted answer
  1. AmanpreetSingh-MSFT 56,556 Reputation points
    2020-10-28T06:25:58.37+00:00

    Hi @Martin D · Welcome to QnA platform and thanks for your query.

    If you request the token under user context (as shown below) and pass that as bearer token in the Authorization header of your API call, you will get all the properties in the response. Below is a snip of how to acquire token under user context.

    35590-image.png

    If you request the token under application context (as shown below) and pass that as bearer token in the Authorization header of your API call, you will only get the "id", "tenantId", and "tenantCategory" in the response

    35607-image.png

    This is expected behavior. To get all the properties in response, you need to update your code to get token under user context using any of Authorization Code/Implicit/ROPC oauth flow.

    Read more: https://learn.microsoft.com/en-us/azure/active-directory/develop/active-directory-v2-protocols

    -----------------------------------------------------------------------------------------------------------

    Please "Accept the answer" if the information helped you. This will help us and others in the community as well.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.