SharePoint Enterprise Content Types and the Graph API

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.

Creating an Enterprise Content Type

From the SharePoint admin center I have created an Enterprise Content Type as shown below:

SharePoint Enterprise Content Types and the Graph API Microsoft Office 365 image 1

Then within my Content Type I’ve created an Enterprise Content Type Site Column as shown below.

SharePoint Enterprise Content Types and the Graph API Microsoft Office 365 image 2

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.

SharePoint Enterprise Content Types and the Graph API Microsoft Office 365 image 3

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.

Enterprise Content Type shown in site's content type gallery

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).

SharePoint Enterprise Content Types and the Graph API Microsoft Office 365 image 5

Once we have added our the content type, the Enterprise Content Type will be available to the Library.

Adding Enterprise Content Type to Library

So far so good! I will now have a look at my Site Content Type Gallery again:

Content Type Gallery showing local copy of Content type

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:

https://pieterveenstramvp.sharepoint.com/sites/TestTeamsite/_api/v2.0/sites/TestTeamsite/ContentTypes

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.

SharePoint Enterprise Content Types and the Graph API Microsoft Office 365 image 8

If I however create a new identical sit the following end point will not give me my Enterprise Content

https://pieterveenstramvp.sharepoint.com/sites/TestTeamsite2/_api/v2.0/sites/TestTeamsite2/ContentTypes

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:

https://pieterveenstramvp.sharepoint.com/sites/TestTeamsite2/_api/v2.0/sites/TestTeamsite2/ContentTypes/getCompatibleHubContentTypes
Enterprise Content Types with Microsoft Graph

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

SharePoint Enterprise Content Types and the Graph API

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

Author: Pieter Veenstra

Share This Post On
Share via
Copy link
Powered by Social Snap