Learning and Sharing
  • Home
  • Blog
  • Linux
  • macOS
  • Virtualization
    • VMware
    • VirtualBox
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
  • Home
  • Blog
  • Linux
  • macOS
  • Virtualization
    • VMware
    • VirtualBox
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
No Result
View All Result

What is the Microsoft Graph API?

October 6, 2023
in Blog, Microsoft Graph
1
ADVERTISEMENT

Table of Contents

What is the Microsoft Graph API?

A basic question, what is Microsoft Graph API?

  • Microsoft Graph is a REST API built on the OData protocol.

So… what does that mean?

  • An API is an Application Programming Interface. Put simply, it is a set of tools that can be used to communicate with an application. Most common APIs are text based and used to access back-end services.
  • A REST API is a web service that allows a client (the requestor) to access resources on an endpoint (the server). REST stands for Representational State Transfer. RESTful services allow requestors to interact with textual resources using a predefined set of operators. REST servers are stateless, which means no client context is stored on the server. The requests themselves supply all the relevant client information in the request.
  • OData stands for Open Data Protocol. It is a standard that defines the best practices for building and interacting with REST APIs. APIs that are built on OData have common structures that make it easier to explore the underlying data.

That’s starting to make sense, but how does that apply to me?

By understanding the basics of how REST APIs are built we can begin to put them into use in our environment. All REST APIs use standard elements when making calls:

  • The Endpoint (URL) is the location where the web service is listening for a request.
  • The Method is a verb that describes the type of request being made. Common methods include:
    • GET – returns a resource
    • POST – creates a resource
    • PUT – updates a resource by replacing all its properties
    • PATCH – updates a resource by changing a single property
    • DELETE – removes a resource
  • Headers include information about the requestor, including client information and the authentication token.
  • The Body includes a payload with information about the request. It is not always required. When accessing Graph, the body will usually be delivered in a JSON payload.

Breaking down a basic request

Now that we you understand the basics of Microsoft Graph, let’s break down a couple simple requests

There are a lot of different ways to access Microsoft Graph. For this post we will use Graph Explorer. Graph Explorer is Microsoft tool that lets you make API calls to Microsoft Graph and see the response.

There are other features available that make Graph Explorer an important tool for understanding Microsoft Graph, but those will be covered more in depth in a later posts.

In our first example we will use the Graph Explorer to return information about our user object from Azure Active Directory.

1️⃣ Open the Graph Explorer by going to https://aka.ms/ge in a browser. In the upper left corner click on Sign into Graph Explorer button. If you don’t sign in you can make test calls to a sample account, but by signing in you will be able to make calls against your own tenant.

Note Note: Click on the images to view at the full size.
lY1AgTAn0xqbSmRHAEm7CDVjf3iMKpABTtyW2oOR6JGyk8mmKBPLztsM5xh9

2️⃣ Sign into Graph Explorer with your username and password.

3️⃣ If your organization has never consented to using Graph Explorer, you may be prompted to consent to allow the application to access your profile information. If you are signed in as an administrator, you can consent for your entire organization. For this example, we will click Accept.

0XlkSlzlEPvIN6dtehy42G5P2E3tlRRgENGuZC3vScPQjmEy7CSfnADg3lo7

4️⃣ Graph Explorer has been pre-populated with a basic API call. The first option is the method dropdown box. In this case we are making a GET call. The second box is the Microsoft Graph version. There are two versions of Microsoft Graph that we can access, v1.0 and beta. You can use either version, but remember the beta endpoint is subject to changes. Finally, we have an address bar where we can enter the URL for the endpoint we would like to access.

ArFQbDgC8pNdgCQjOzLj2MDNXsdrSe8PL28yImVu2g3lsS3ALgjCTMKv1tn0

5️⃣ The default endpoint for this query is https://graph.microsoft.com/v1.0/me. This query returns the querying user’s Entra ID user object. In this example we returned the logged in user’s user object:

9JTEMcVHrd2peCdzyn73TaJ1urU6CDajH8tqe1SSvM9RmAYFJJcPumatQxlX

In the upper left corner, the response status is displayed. This request took 1300 ms, and returned a status of 200, which means it was successful.

6️⃣ On the left side of Graph Explorer, we see several sample queries. Scroll down to users, expand it, and select “Patch me.” We will use this sample to make another API call to PATCH our user object.

The GET request above didn’t include a body. Requests that will create or update objects will require information about the update to be made. In this case when we selected the sample query it changed the selected method to “PATCH,” and filled in the body with a JSON payload. For this example we will update the user’s department. The endpoint is still pointing at https://graph.microsoft.com/v1.0/me because we are updating the logged in user’s AD User object.

tIAnf7JNnYfcaFKHEzGIBhIV91ddlsOh7W8EzV6vwZDdEHtHNquXfCDxSgCq

7️⃣ If we click on the “Request headers” tab, we can see that this request includes the content type in the headers. This tells the service the type of payload that is being included in the request. Here we see that our content type is application/json.

ypSHrVGtwEk5U2p9FHqVBaZXjb9eXbsFNQYdm6YCvW9P8RNzaWRtNDaMA08H

8️⃣ Finally, we can click on the Access token to see the token that is being passed. Each request passes an access token to the service with information about the requestor and their permissions. The token has a limited lifetime, but we can use it in other services to make requests until it expires. We can also view the contents of the token by clicking on the bracket icon {}. I will discuss the token more in depth in a later post.

9j01hVWWqlcuaWpf1P43HVLFVBqTGJtAn3t0e4Ju13fuPQrqrmVLKcbxXFPW

If you get the error Forbidden 403. It means you need to click on the Modify permission tab then consent more permission for this call.

nDtn5IepguycvaBdh5NayDWATtz0gZ4twUEDBd1sC3EIvbTw1U6p44M7E5nW

For instance, we need to consent the User.ReadWrite.All permission to the app.

gE1kygk8Y0a2pyoCgUSPYHhEOfXcDw6dWmlInwsbGvTTObbIoAyS4uktjLJx

9️⃣ After clicking on the Run query button, we receive a response that says, No content with a status of 204. This looks like it was successful, but since there was no content returned, we need to return the user object to see if the department changed.

E3WBi1LjiILMHoK646tXGxzZqeoL6pyVJ9Y24WIJayCKZRF4ebPpX8pAH3lB

🔟 When we run the original query above no department was returned. By default, not all properties are returned. Query options can be added to the end of the URL to change the information that is returned. Returned properties can be changed by using a select query option. Changing the selected properties can be done by appending ?$select=property1.property2,property3 to the end of the original query.

https://graph.microsoft.com/v1.0/me?$select=department,displayName,userPrincipalName
2uf2abv7cUZZ7dnUAVbxxpwj85BSEzLkSj3RLTxrU5Sw8iSMBe0xOQ4fJIDm

Here we can see that we received the response “OK” with a status code of 200. The response includes the properties that we included in our select query above. We can also see that the department was successfully updated.

This blog post was intended to be an entry point for using Microsoft Graph.

5/5 - (1 vote)
Previous Post

How to Disable the Yellow Bulb in Visual Studio Code

Next Post

How to Use Splatting with Invoke-RestMethod in Graph PowerShell

Related Posts

Running Hyper-V and VMware Workstation on The Same Machine

August 15, 2024

How to Uninstall All Autodesk Products At Once Silently

July 29, 2024
Ftr5

How to Uninstall the Autodesk Genuine Service on Windows

July 29, 2024
Ftr19

How to Fix Windows Cannot Read the ProductKey From the Unattend Answer File in VirtualBox

July 26, 2024
Ftr25

How to Update Windows Terminal in Windows 10/11

July 26, 2024

How to Disable The Beep Sound in WSL Terminal on Windows

July 26, 2024

Comments 1

  1. Anonymous says:
    2 years ago

    ciao

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • How To Turn On uBlock Origin Extension in Chrome (2025)
  • Images Hidden Due To Mature Content Settings In CivitAI
  • Azure OpenAI vs Azure AI Hub, How to Choose the Right One for Your Needs

Categories

Stay in Touch

Discord Server

Join the Discord server with the site members for all questions and discussions.

Telegram Community

Jump in Telegram server. Ask questions and discuss everything with the site members.

Youtube Channel

Watch more videos, learning and sharing with Leo ❤❤❤. Sharing to be better.

Newsletter

Join the movement and receive our weekly Tech related newsletter. It’s Free.

General

Microsoft Windows

Microsoft Office

VMware

VirtualBox

Technology

PowerShell

Microsoft 365

Microsoft Teams

Email Servers

Copyright 2025 © All rights Reserved. Design by Leo with ❤

No Result
View All Result
  • Home
  • Linux
  • Intune
  • macOS
  • VMware
  • VirtualBox
  • Powershell
  • Windows 10
  • Windows 11
  • Microsoft 365
  • Microsoft Azure
  • Microsoft Office
  • Active Directory

No Result
View All Result
  • Home
  • Linux
  • Intune
  • macOS
  • VMware
  • VirtualBox
  • Powershell
  • Windows 10
  • Windows 11
  • Microsoft 365
  • Microsoft Azure
  • Microsoft Office
  • Active Directory