Microsoft Graph

What is Microsoft Graph?

Microsoft Graph exposes REST APIs and client libraries to access data on the following Microsoft 365 services:

  • Office 365 services: Delve, Excel, Microsoft Bookings, Microsoft Teams, OneDrive, OneNote, Outlook/Exchange, Planner, and SharePoint
  • Enterprise Mobility and Security services: Advanced Threat Analytics, Advanced Threat Protection, Azure Active Directory, Identity Manager, and Intune
  • Windows 10 services: activities, devices, notifications
  • Dynamics 365 Business Central

What Is Microsoft Graph Explorer?

Microsoft Graph Explorer is a web-based tool that helps you build and test queries in order to interact with Microsoft resources. So, in this post, I will use it to manage data. You can access to Microsoft Graph Explorer from this link: https://developer.microsoft.com/en-us/graph/graph-explorer#

Microsoft Graph Explorer

The first thing you need to do is to sign in with your account in order to access your own data. If you use Graph Explorer without your account, you will use the demo data. So click “Sign in with Microsoft”.

Sign in with Microsoft

The following part allows you to interact with your Microsoft resources. It can be divided in three parts:

Run Query

First, you can choose the action you want to perform:

Choose the action you want to perform

  • GET: Read data from a resource.
  • POST: Create a new resource or perform an action.
  • PUT: Replace a resource with a new one.
  • PATCH: Update a resource with new values.
  • DELETE: Remove a resource.

Next, you can select the API version you want to use:

Select the API version

  • V1.0 : Includes generally APIs. You can use this version for all production apps.
  • Beta : Includes APIs that are currently in preview. Microsoft recommends to not use beta APIs in production.

Then, there is the resource field which always starts with: https://graph.microsoft.com. This field allows you to insert the resource you want to manage. Below is the link that will be used:

  • Graph link + API version + Resource link

For instance, the full resource link could be:

https://graph.microsoft.com/v1.0/me/drive/recent

The following textbox allows you to enter the new value to create or the date you want to update.

Textbox allows you to enter the new value

The following textbox will display data or error messages:

Textbox will display data or error message

Let’s start by running the following query to display your information:

https://graph.microsoft.com/v1.0/me/

Graph Explorer

You can use sample queries on the left side by clicking “show more samples”, then turn on/turn off the sample categories you want to use:

Sample queries

Sometimes you can see the following error message:

Error message

This error means that you need specific permissions in order to use this query. Let’s see how to manage these permissions.

The first step is to check the documentation page https://docs.microsoft.com/en-us/graph to identify the permissions you have to allow. In my case, I want to read my OneNote notebooks:

Permissions

The second step is to click “modify your permissions” in the error message in order to enable the permissions:

Modify permissions

After applying the permissions, you need to log in again to refresh the permissions in Graph Explorer. Run the query to confirm that you can access your OneNote notebooks:

OneNote notebooks

Copy the OneNote Notebook ID in order to create a new section:

  1. Select the POST action, because we want to create a resource
  2. Paste the following link: https://graph.microsoft.com/v1.0/me/onenote/notebooks/<ID>/sections and modify the ID
  3. Enter the name of the new section that will be created in the “Request Body” textbox.

Request Body

Let’s check my OneNote and confirm that a new section named “Section from MS graph Explorer” is visible:

Section from MS graph Explorer

VSAN from StarWind eliminates any need for physical shared storage just by mirroring internal flash and storage resources between hypervisor servers. Furthermore, the solution can be run on the off-the-shelf hardware. Such design allows VSAN from StarWind to not only achieve high performance and efficient hardware utilization but also reduce operational and capital expenses.

Learn more about ➡ VSAN from StarWind

Conclusion

Thanks to the Graph API, we can very easily interact with the Microsoft resources. In this guide, I worked with OneNote, but a useful use case could be to interact with Microsoft Teams in order to create a new Teams/Channel, to add a member, and so on …

To finish, you can of course interact with the Graph API from your code as described on the following picture:

 Graph API

Views All Time
6
Views Today
11
Appreciate how useful this article was to you?
1 vote, average: 5.00 out of 51 vote, average: 5.00 out of 51 vote, average: 5.00 out of 51 vote, average: 5.00 out of 51 vote, average: 5.00 out of 5
5 out of 5, based on 1 review
Loading...
Back to blog
The following two tabs change content below.
Nicolas Prigent
Nicolas Prigent
Nicolas Prigent works as an IT Production Manager, based in Paris, with a primary focus on Microsoft technologies. Nicolas is a three-time Microsoft MVP in Cloud and Datacenter Management with 10 years experience in administering Windows products. He also received the "PowerShell Heroes 2016" Award.