top of page

Introduction to Microsoft Graph API – Part 1

Updated: Dec 27, 2023

Introduction to Microsoft Graph

Microsoft Graph is a RESTful web API that enables you to access Microsoft Cloud service resources

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

  1. Office 365 services: Delve, Excel, Microsoft Bookings, Microsoft Teams, OneDrive, OneNote, Outlook/Exchange, Planner, and SharePoint

  2. Enterprise Mobility and Security services: Advanced Threat Analytics, Advanced Threat Protection, Azure Active Directory, Identity Manager, and Intune

  3. Windows 10 services: activities, devices, notifications

  4. Dynamics 365 Business Central

Graph
  1. The Microsoft Graph API offers a single endpoint, https://graph.microsoft.com, to provide access to rich, people-centric data and insights exposed as resources of Microsoft 365 services. You can use REST APIs or SDKs to access the endpoint and build apps that support scenarios spanning across productivity, collaboration, education, security, identity, access, device management, and much more

  2. Microsoft Graph Data Connect provides a set of tools to streamline secure and scalable delivery of Microsoft Graph data to popular Azure data stores. This cached data serves as data sources for Azure development tools that you can use to build intelligent applications.

Let’s park the discussion about the Graph API for while and start practically validating it.

As I have already said, Microsoft Graph API is Restful API Call and it can connect to complete cloud Services using the https://graph.microsoft.com or SDK.

First, Let’s see how it works before we get into code way using the Graph API.

Let’s login to https://developer.microsoft.com and click on the Graph Explorer


Graph

click on Sign in and login using the Office365 User accounts.

Note: You can login using the normal account which ideally gives results of the account logged in. if you login using the Admin Privileged Account which will fetch information for all the accounts of the tenant.

Graph

Click on Sign In with Microsoft and login again with Office 365 User account


Graph

Alright. We have logged in to the portal and let’s try to check what we can do with the Portal now


Highlighted below is the Query Area which we can use to query Microsoft Cloud Work Loads.


Graph

HTTP Methods Below are the HTTP Methods, Microsoft Graph uses the HTTP method on your request to determine what your request is doing. The API supports the following methods.

Graph

  1. For the CRUD methods GET and DELETE, no request body is required.

  2. The POST, PATCH, and PUT methods require a request body, usually specified in JSON format, that contains additional information, such as the values for properties of the resource.

Graph

Version

Microsoft Graph currently supports two versions: v1.0 and beta.

  1. v1.0 includes generally available APIs. Use the v1.0 version for all production apps.

  2. beta includes APIs that are currently in preview. Because we might introduce breaking changes to our beta APIs, we recommend that you use the beta version only to test apps that are in development; do not use beta APIs in your production apps.

When you try to Run Query for the logged-in User with Query https://graph.microsoft.com/v1.0/me


Graph

We could see that Success – Status Code 200 and the Response.

Graph

You can see the Response Headers of the Query.


If required to query other users or other cloud resources, we should first get the Consent for the specific workload before we proceed with running the Query.

Graph

If it is Consented to, we should be able to proceed with specific workload, if it is Admin consent still not done, we should not be able to proceed. So be specific to the requirements and the admin consent.

Graph

Let’s consider as per the above screenshot, We already have Consent for the Users.ReadBasic.All.

Run Query https://graph.microsoft.com/v1.0/users/ to get all the users for the complete Office 365 Tenant.

Graph

Likewise, we can still execute for the Groups to get all the office 365 Groups.

Run Query https://graph.microsoft.com/v1.0/groups to get all the Groups available

Graph

If you would like to apply with a specific filter and get the results for it, you can still able to execute it.

Graph

Likewise, we can connect with different workloads and do all the http methods mentioned.

In Next Article, we will go ahead and proceed with interact using the Codes.

11 views0 comments
bottom of page