In this blog, we will be learning about Microsoft Graph Extensibility - Open Type Extension.
What are Microsoft Graph Extensions?
Microsoft Graph provides a single API endpoint to access rich people-centric data and insights through resources such as user and message. You can also extend Microsoft Graph by adding custom properties to resource instances without requiring an external data store.Microsoft Graph offers four types of extensions for adding custom data.
- Extension attributes
- Directory (Microsoft Entra ID) extensions
- Schema extensions
- Open extensions
Open Extensions
Here we will be discussing Open extensions.
- It allows us to add untyped properties to resources in Graph.
- Each extension has a key/value property.
- The name of the extensions should include a reverse domain name system (DNS) format that is dependent on our own domain; for example, the DNS name com.mydomain.UserInfo
- Can be added, updated, and deleted.
⊛ Note
Do not use extensions to store sensitive personally identifiable information, such as account credentials, government identification numbers, cardholder data, financial account data, healthcare information, or sensitive background information.
Resource | Status | Permission |
---|---|---|
Administrative unit | Preview Only | Directory.AccessAsUser.All |
Calendar event | GA | Calendars.ReadWrite |
Group calendar event | GA | Group.ReadWrite.All |
Group conversation thread post | GA | Group.ReadWrite.All |
Device | GA | Device.ReadWrite.All |
Group | GA | Group.ReadWrite.All |
Message | GA | Mail.ReadWrite |
Organization | GA | Directory.AccessAsUser.All |
Personal contact | GA | Contacts.ReadWrite |
User | GA | Directory.AccessAsUser.All |
We will be working around User resource in the Graph
Open Microsoft Graph Explorer - aka.ms/ge
The first thing is to provide permissions (refer to the above table) to use the Microsoft Graph API endpoint.
Get an Extension
Enter the below table details and press the 'Run query' button. We will get OK-200 status and blank/empty array as we currently don't have any extensions available. (we'll get extensions again further in the blog).
Verb | GET |
---|---|
URL | https://graph.microsoft.com/v1.0/me? $select=id,displayName,mail,mobilePhone&$expand=extensions |
Create an Extension
Enter the below table details and press the 'Run query' button. The new open extension will be created, and we will get Created-201 status.
Verb | POST |
---|---|
URL | https://graph.microsoft.com/v1.0/me/extensions |
Body |
|
Update an Extension
Enter the below table details and press the 'Run query' button. The open extension value will be updated, and we will get a No Content-204 status.
{Extension-Id} is the name of the extension previously created.
Verb | PATCH |
---|---|
URL |
https://graph.microsoft.com/v1.0/me/extensions/{extension-id} https://graph.microsoft.com/v1.0/me/extensions/com.vikasbansal.userSettings |
Body |
|
Again, enter the Get extension table details and press the 'Run query' button. We will get OK-200 status, and the extensions array will contain available extension details against the user resource in Graph.
Delete an Extension
Enter the below table details and press the 'Run query' button. The open extension will be deleted, and we will get a No Content-204 status.
{Extension-Id} is the name of the extension previously created or updated.
Open Extension once deleted, cannot be restored but can be created again with the same name.
Verb | DELETE |
---|---|
URL |
https://graph.microsoft.com/v1.0/me/extensions/{extension-id} https://graph.microsoft.com/v1.0/me/extensions/com.vikasbansal.userSettings |
Open Extensions: Limitations and Useful Information
- Resources cannot be filtered based on open extensions.
- Each open extension can have up to 2 KB of data (including the extension definition).
- An application can add up to two open extensions per resource instance.
- There is no transaction context while working on extensions.
I hope this will help all of you! 🧲
Feel free to provide feedback.
🚀 "Happy Coding" 🚀
Nice
ReplyDelete