List of all posts in the #30DaysMSGraph series
In Day 2 we discussed what is Microsoft Graph and what services are included. Today we’ll cover how to make your first call against Microsoft Graph using the Graph Explorer.
While it may be great to read about Microsoft Graph and all that it can do it is equally important to see it in action. Thankfully, Microsoft Graph product group has made it extremely easy to test out queries and view examples against a demo tenant or live on your own tenant.
You can find the Graph Explorer at https://developer.microsoft.com/en-us/graph/graph-explorer or the shortcut https://aka.ms/ge (“ge” for Graph Explorer.)
The Graph Explorer offers several useful items for getting started with minimal effort. When you first access the Graph Explorer you will be able to run commands against a demo environment without needing to log in. If you wish to test out calls against your own Office 365 tenant, you can log in using the “Sign in with Microsoft” button on the upper left portion of the screen.
Additionally, there are dozens of sample requests provided across multiple services.
Note that if you sign into your own tenant you may receive an error message if you call an endpoint that you do not have the appropriate permissions required. The error will look similar to the following:
Click modify permissions in the upper left under your profile image and name (or modify your permissions from the error message above).
If granting admin consent (on behalf of all other users in tenant, more on this in a later post) check the box. Then click Accept.
Lastly, some Azure Active Directory administrators configure the domain to not allow end users to consent to applications. If this is the case for your domain then you may receive an error message similar to the following after attempting to grant permissions:
We will discuss more about scenarios like this in a later post.
Try It Out
Navigate to the Graph Explorer. Try the following calls to Microsoft Graph using the demo tenant or logging into your own tenant.
- Get logged in user
Sample response:
{ "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users/$entity", "id": "48d31887-5fad-4d73-a9f5-3c356e68a038", "businessPhones": [ "+1 412 555 0109" ], "displayName": "Megan Bowen", "givenName": "Megan", "jobTitle": "Auditor", "mail": "MeganB@M365x214355.onmicrosoft.com", "mobilePhone": null, "officeLocation": "12/1110", "preferredLanguage": "en-US", "surname": "Bowen", "userPrincipalName": "MeganB@M365x214355.onmicrosoft.com" }
- Get logged in user’s manager
Sample response:
{ "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#directoryObjects/$entity", "@odata.type": "#microsoft.graph.user", "id": "24fcbca3-c3e2-48bf-9ffc-c7f81b81483d", "businessPhones": [ "+1 205 555 0108" ], "displayName": "Diego Siciliani", "givenName": "Diego", "jobTitle": "CVP Finance", "mail": "DiegoS@M365x214355.onmicrosoft.com", "mobilePhone": null, "officeLocation": "14/1108", "preferredLanguage": "en-US", "surname": "Siciliani", "userPrincipalName": "DiegoS@M365x214355.onmicrosoft.com" }
Join us tomorrow as we inspect the syntax for Microsoft Graph requests in Day 4.