SharePoint Enterprise Content Types and the Graph API
Creating an Enterprise Content Type
From the SharePoint admin center I have created an Enterprise Content Type as shown below:
Then within my Content Type I’ve created an Enterprise Content Type Site Column as shown below.
Both my content type and my site column start with an underscore so that they appear at the top of the overviews. Which helps with the screenshots in this post. Normally there is no reason for doing this.
Now that I have my content type there I will publish my Enterprise Content Type and my sites will now be able to use the Content Type.
Enterprise Content Type in SharePoint sites
Now we can check if the Enterprise content type is available within the SharePoint Sites. Yes, this should be quite instant however, I’ve seen a number of times recently that provisioning processes struggle when multiple sites are created at the same time.
We should however expect to see our content type arriving to a newly created site as shown below.
Adding Enterprise Content Types to a Document Library
Using the Add from existing site content types in the Library Settings, we can now add our Enterprise Content Type to a library (or list).
Once we have added our the content type, the Enterprise Content Type will be available to the Library.
So far so good! I will now have a look at my Site Content Type Gallery again:
Notice that the Content Type source has now changed. Do we have a local site content type now? When testing this out the publishing process still works. So no immediate reason for panic
And even if we were to Delete the content type from the Library the local copy of the Content Type will remain on the site. For people familiar with SharePoint site scripts, it looks like the adding of an Enterprise Content Type to a library, will force an addContent TypesFromHub operation.
Using the Graph API to get the Content types
So far the long introduction to my post today. Remember at the start of this post, I was going to include the Graph API.
In my case I wanted to check if the Enterprise content types had arrived to my site. Normally this should happen within a minute however I’ve seen delayed of nearly 10 minutes in provisioning processes as well.
There are a couple of end points that are important here. The first end point in the Graph API gives us all the Content Types on the site:
When we look at the site where I added my content type to the document library we will find our content type back in the output supplied by the above end point.
If I however create a new identical sit the following end point will not give me my Enterprise Content
Ok, so how can we check if the Enterprise Content Type has arrived or not?
Find the Enterprise Content Types with Microsoft Graph
There is another endpoint that will give us the Enterprise Content Types
The getCompatibleHubContentTypes endpoint will help us here:
So what is the getCompatibleHubContentTypes endpoint giving us? We do get list of content types here that are in my Enterprise Content Type Gallery, but not all of them. Obviously only the published content types are included in the list returned by the getCompatibleHubContentTypes endpoint, but …
The getCompatibleHubContentTypes endpoint is actually even cleverer.
Imagine if your Enterprise Content types depends on Document Sets (or any other feature) and Document Sets haven’t been enabled on your destination site, then you will find that the content type in question is not seen as compatible and therefore is not returned by the endpoint.
Continue Reading Pieter Veenstra’s Article on their blog
Following my posts about the Content Type Gallery and my series about the Graph API, today a post about Enterprise Content Types in SharePoint and how to access them through the Graph API. From the SharePoint admin center I have created an Enterprise Content Type as shown below: Then within my Content Type I’ve created an Enterprise Content Type Site Column as shown below.
Blog Syndicated with Pieter Veenstra’s Permission
More About This Author
- Modern Workplace5 December 2023Auto height, Containers and flexible font sizes in Power Apps
- Modern Workplace3 December 2023Connect to Microsoft Graph using PowerShell with certificates
- Modern Workplace3 December 20234 new undocumented functions to encode and decode Xml in Power Automate
- Modern Workplace3 December 2023A scheduled flow that locks an app