seebiscuit
seebiscuit

Reputation: 5063

Get definite schema information for Microsoft Graph requests

I have an Office JavaScript add-in. We handle our own license workflow. Part of the workflow is to use office-js-helpers to handle Microsoft logging. The user uses the Microsoft endpoint to log in and we receive an access token which we send to https://graph.microsoft.com/v1.0/me to retrieve user data. Some users are individual Microsoft users, others are part of an organization.

Recently, I've noticed that the givenName field is not provided, and it's causing errors in ingestion. I find it hard to design a schema to handle user data coming from MS Graph, since I have not seen any schema information for the possible responses to me request.

Can someone point me to where MS lists the definite schema for it's Graph requests? Is there a request URI for that kind of info?

Upvotes: 1

Views: 561

Answers (1)

Vadim Gremyachev
Vadim Gremyachev

Reputation: 59358

The underlying object schema could be determined by specifying odata=fullmetadata JSON control level as demonstrated below:

Url: https://graph.microsoft.com/v1.0/me
Method: Get
Headers
   Accept: application/json;odata.metadata=full;odata.streaming=false;IEEE754Compatible=false

which returns the type name of the containing object (odata.type annotation), in case of https://graph.microsoft.com/v1.0/me endpoint it is #microsoft.graph.user

And then via Microsoft Graph API metadata endpoint:

Url: https://graph.microsoft.com/v1.0/$metadata
Method: Get

where microsoft.graph.user entity schema could be found under under Schema element for Namespace="microsoft.graph":

<EntityType Name="user" BaseType="microsoft.graph.directoryObject" OpenType="true">
    <Property Name="accountEnabled" Type="Edm.Boolean" />
    <Property Name="ageGroup" Type="Edm.String" />
    <Property Name="assignedLicenses" Type="Collection(microsoft.graph.assignedLicense)" Nullable="false" />
    <Property Name="assignedPlans" Type="Collection(microsoft.graph.assignedPlan)" Nullable="false" />
    <Property Name="businessPhones" Type="Collection(Edm.String)" Nullable="false" />
    <Property Name="city" Type="Edm.String" />
    <Property Name="companyName" Type="Edm.String" />
    <Property Name="consentProvidedForMinor" Type="Edm.String" />
    <Property Name="country" Type="Edm.String" />
    <Property Name="department" Type="Edm.String" />
    <Property Name="deviceKeys" Type="Collection(microsoft.graph.deviceKey)" Nullable="false" />
    <Property Name="displayName" Type="Edm.String" />
    <Property Name="employeeId" Type="Edm.String" />
    <Property Name="givenName" Type="Edm.String" />
    ...
  </EntityType>

Upvotes: 1

Related Questions