Allow management of Content Types on SharePoint Lists using Power Automate

Within SharePoint there is the option to allow management of content types. But how do you manage this setting within Power Automate?

Allow management of content types
Allow management of content types

Management of Content Types

First, of all, why would we need to enable content types on a library. In both cases the New menu in the library will show your content types.

Even if you haven’t enabled the Allow management of content types you will still find that a lot of the API calls on the lists will simply ignore this setting. It might even feel like this setting doesn’t matter other then if you want to add or remove content types through the SharePoint library settings user interface.

When you have a library where the management of content types is disabled and you use the get file properties action to retrieve the content type of the library, then the content type details for your files and folder are not being returned.

Content Types not returned
Content Types not returned

Where if we enable the setting the Get File Properties action output will look like this:

...
"{FullPath}": "Shared Documents/Folder1",
  "{ContentType}": {
    "@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedContentType",
    "Id": "0x012000A235779F9928584AB5D2CA8E3028D13D",
    "Name": "Folder"
  },
  "{ContentType}#Id": "0x012000A235779F9928584AB5D2CA8E3028D13D",
...

If we need a flow to know the content type used by a file or folder then we will need to enable the setting on the library.

Enable Management of Content Types

To Enable the Management of content types we can build a small flow as follows:

Allow management of content types on a SharePoint library
Allow management of content types on a SharePoint library

The end point used is:

_api/web/Lists/getByTitle('Documents')

The Headers of the action are set like this:

{
  "Content-type": "application/json; odata=verbose",
  "Accept": "application/json; odata=nometadata",
  "IF-MATCH": "*",
  "X-HTTP-Method": "MERGE"
}

The body is set like this:

{
   "__metadata": { "type": "SP.List" },
   "ContentTypesEnabled" : true
}

And that is it! A quick simple solution for an annoying problem.


Discover more from SharePains

Subscribe to get the latest posts sent to your email.

Related Posts

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.