Introduction
Microsoft graph is the doorway to information and knowledge in Microsoft 365. It gives a brought together programmability model that you can use to get to the enormous amount of information in Microsoft 365. Recently, one more bundle for ContentType APIs has been added in Microsoft Graph Beta.
This article will cover Content-Type APIs to Get, Add, Update, Delete activity for Content Type in SharePoint Site.
How to enroll application in azure Portal to access graph API Endpoint?
If we need to access or get the information across Microsoft 365 cloud applications, we should enlist our application in the App Registration Portal in Azure Portal, since all administrations are coordinated with the Microsoft Identity Platform to give secure sign-in, provide access token for application and approval for their administrations.
To Register App in Azure Portal, Please follow article which is provided by Microsoft Soft.
To Register App in Azure Portal, Please follow article which is provided by Microsoft Soft.
How to generate an access Token to access resources using Microsoft Graph?
I am under the understanding that you have registered your app and you have Client ID/ Application ID, Tenant ID, and Secrete key in hand.
- End Point
- Get https://login.microsoftonline.com/<Tenent Id>/oauth2/v2.0/token
- Body
- grant_type:client_credentials
- client_id: <Application Id>
- client_secret: <Client Secrete>
- scope:https://graph.microsoft.com/.default
Response as below,
- {
- "token_type": "Bearer",
- "expires_in": 3599,
- "ext_expires_in": 3599,
- "access_token": "eyJ0eXAiOiJKV1QiLCJub25jZSI6ImwtemtxV05pOUt1NHhhbFJLOWh3ZUNxX2J6UUJzM0J6WTRjbkRTaVctMDQiLCJhbGciOiJSUzI1NiIsIng1dCI6Im5PbzNaRHJPRFhFSzFqS1doWHNsSFJfS1hFZyIsImtpZCI6Im5PbzNaRHJPRFhFSzFqS1doWHNsSFJfS1hFZyJ9.eyJhdWQiOiJodHRwczovL2dyYXBoLm1pY3Jvc29mdC5jb20iLCJpc3MiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC8zZDI0ZTM2OS0xMjhhLTQxOWYtYTQ1Ny02NTk3MzgzMzlkZjMvIiwiaWF0IjoxNjE5NzgxMTIwLCJuYmYiOjE2MTk3ODExMjAsImV4cCI6MTYxOTc4NTAyMCwiYWlvIjoiRTJaZ1lNallXQ25QVUhxTVI2clBhb0tRazRnekFBPT0iLCJhcHBfZGlzcGxheW5hbWUiOiJDb250ZW50VHlwZUFwcCIsImFwcGlkIjoiMjQ2NTI5MzQtZDIzMy00ZDQ0LWI1MTEtOTVkYWExMzNmZmJkIiwiYXBwaWRhY3IiOiIxIiwiaWRwIjoiaHR0cHM6Ly9zdHMud2luZG93cy5uZXQvM2QyNGUzNjktMTI4YS00MTlmLWE0NTctNjU5NzM4MzM5ZGYzLyIsImlkdHlwIjoiYXBwIiwib2lkIjoiZmQwNWEzYzctMDE3Yi00ZDY3LTg0MGItZjBhOWExODdhZDgzIiwicmgiOiIwLkFYQUFhZU1rUFlvU24wR2tWMldYT0RPZDh6UXBaU1F6MGtSTnRSR1YycUV6Xzcxd0FBQS4iLCJyb2xlcyI6WyJTaXRlcy5SZWFkLkFsbCIsIlNpdGVzLlJlYWRXcml0ZS5BbGwiXSwic3ViIjoiZmQwNWEzYzctMDE3Yi00ZDY3LTg0MGItZjBhOWExODdhZDgzIiwidGVuYW50X3JlZ2lvbl9zY29wZSI6IkFTIiwidGlkIjoiM2QyNGUzNjktMTI4YS00MTlmLWE0NTctNjU5NzM4MzM5ZGYzIiwidXRpIjoiV21mUlBLWWJWRXVLVjdWSWpndjdBUSIsInZlciI6IjEuMCIsInhtc190Y2R0IjoxNjE1NjExMDE0fQ.Djs_iSdUTySvT-kCsFTFbZUbwXcPoAAHhJPzKRV9uy-IavXFAhjJzYpHHPmSqi6qzZbwn-cPVZVs4ics4LrD64ILStblft_1f8r"
- }
Permission
Permission should be selected in-app which is registered,

Permission should be selected in-app which is registered,

How to create content Type using Microsoft Graph in SharePoint list?
The accompanying model tells the best way to make another conventional content type.
SharePoint Content Type IDs
SharePoint Content Type IDs
- Post https://graph.microsoft.com/beta/sites/<Site Id>/contentTypes
- Header
- {
- "Content-Type":"application/json"
- "Authorization":"Bearer <Access Token>"
- }
- Body
- {
- "name": "Document Set for Article",
- "description": "Demo Document Set",
- "base": {
- "name": "Document Set for article",
- "id": "0x0120D520"
- },
- "group": "Document Set Content Types"
- }
Site ID will be your SharePoint site ID.
- <TenentName>.sharepoint.com,9f1b3366-1a6b-49d3-920a-2f38c873cb1b,20a80558-c545-4b79-8f75-dba806ea176f
<Domain>.sharepoint.com,<Site ID>,<Web Id>

HappyCoding
Join the conversation! Your thoughts help the community grow.