There are some new SharePoint Premium Content AI Microsoft Graph API endpoints. Allowing you through code to programmatically orchestrate document processing models. This allows scenarios such as provisioning a site and then applying a model to a library or processing a file/folder using a model to now be completed using Microsoft Graph.

These commands have previously been available using Microsoft Syntex unstructured document processing model REST API which relies on making SPO REST calls. It’s great to see these commands now coming to Microsoft Graph!

I will now test all the new Content Model Graph API endpoints and provide the commands required to execute the MS Graph commands using PowerShell

Permissions Required/Connecting

To authenticate to Graph an App registration is required, below is how I did it. I am unsure the permissions required for executing the SP Premium Graph commands but I found Sites.FullControl.All worked for my testing.

I then connected using Connect-PnPOnline using the details I obtained from creating the SPPremiumMSGraph app registration.

Once connected I could then test the commands.

Get Content Model

Official Docs: Get contentModel – Microsoft Graph beta

This Graph command (GET) allows you to GET the details of Document Processing model by providing the ID.

Result: This shows a JSON payload showing further details of the model and when it was last modfied, created modelType, createdBy etc.

Get Applied Drives

Official Docs: contentModel: getAppliedDrives – Microsoft Graph beta

This Graph command (GET) allows you to find out all the document libraries that a document processing model is applied to.

Result: This returns a JSON array with all the different Drives (Document Libraries) where the model is applied to.

Get By Name

Official Docs: contentModel: getByName – Microsoft Graph beta

This Graph command (GET) allows you to retrieve a model in a Content Centre by specifying the name of the model ensuring the name includes “.classifier”.

Result: This shows a JSON payload showing further details of the model and when it was last modfied, created modelType, createdBy etc.

Add To Drive

Official Docs: contentModel: addToDrive – Microsoft Graph beta

This Graph command (POST) allows you add a SharePoint Premium document processing model to a drive (document library. Use the Graph command GET /sites/{site Id}/drives (To fetch drive IDs for a particular site).

Result: This shows details of the library & model applied along with created/modified details.

Remove From Drive

Official Docs: contentModel: removeFromDrive – Microsoft Graph beta

This graph commands allows you to remove a SharePoint Premium document processing model from being applied to a library.

Result: No payload is returned on success

Create Document Processing Job

Official Docs: Create documentProcessingJob – Microsoft Graph beta

This command is used to initiate a file or a folder for re-processing with any models applied to the library.

File

Result: This shows details of the file marked for reprocessing.

Folder

Result: This shows details of the folder marked for reprocessing.

Summary

It’s great that SP Premium is now coming to MS Graph and a very welcome addition. This should help with some orgs who are wanting to use MS Graph first and not rely on the older SPO REST API calls for models.

I personally cannot wait for other SP Premium commands i.e. trigger Content Assembly document generation to become available. This will be a killer to allow document generation from code at a large scale – Imagine contracts, job sheets etc being generated automatically!

Although the Graph commands are in beta and are subject to change – they were easy to follow and execute. I look forward to implementing document processing model MS Graph commands into provisioning solutions to ensure models are also provisioned at the same time.

Leave a Reply