Introduction to Microsoft Graph API – Part 1

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:

  • 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

To find out more, see Major services and features in Microsoft 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

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.

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

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

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

HTTP Methods

Below is 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.

MethodDescription
GETRead data from a resource.
POSTCreate a new resource, or perform an action.
PATCHUpdate a resource with new values.
PUTReplace a resource with a new one.
DELETERemove a resource.
  • For the CRUD methods GET and DELETE, no request body is required.
  • The POSTPATCH, 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.

Version

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

  • v1.0 includes generally available APIs. Use the v1.0 version for all production apps.
  • 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

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

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 work load before we proceed with running the Query.

If it is Consented, 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.

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.

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

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

https://graph.microsoft.com/v1.0/groups?$filter=startswith(DisplayName,’windowstechpro’)

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.

Introduction to Microsoft Graph API – Part 2

Introduction to Microsoft Graph API – Part 3