cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

Change Sharepoint library settings"Allow management of content types" using power automate

Hi,

 

I am trying to change the "Allow management of content types" setting on an existing library to test the behaviour. We are currently building a new structure of sites and the sites themselves have been created but this setting needs to be enabled on all of them.

 

Is this possible or is this a setting that can only be provided during the creation of the document library?

 

Afterwards I would have to add a custom content type to the document library. How should I do this as I have been looking this up and it seems that the way you do this has changed recently.

 

What I have tried so far is this:

MatthiasVeelaer_0-1688461659848.png

but this gives an error as Patch is not supported on the list collection.

 

I have also tried it with post but then I get this error(which I guess has to do with the fact that it thinks I'm trying to create a library and therefore provide no library title):

MatthiasVeelaer_0-1688462245724.png

 

If anyone has an idea of what I could do that would be much appreciated! Thanks!

20 REPLIES 20
Expiscornovus
Most Valuable Professional
Most Valuable Professional

Hi @MatthiasVeelaer,

 

You can use a POST method for this. You do need to provide which list/library you want to update in the URI field though, otherwise it would not know which library you want to update.

 

Below is an example

 

URI

_api/web/lists/getbyTitle('@{variables('ListName')}')

 

Headers

{
  "Accept": "application/json;odata=verbose",
  "Content-Type": "application/json;odata=verbose",
  "If-Match": "*",
  "X-HTTP-Method": "MERGE"
}

 

Body

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

 

allowcontenttypes_restapi.png

 



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #MicrosoftCopilotStudio content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


Perfect! Thanks Expiscornovus this worked like a charm! 

Now how would I go about actually adding the content type to the library through power automate as it seems the way to do this has been changed very recently?

 

Thanks so much already though!

Expiscornovus
Most Valuable Professional
Most Valuable Professional

Hi @MatthiasVeelaer,

 

If the content type already exists in the site (has been published from the content type gallery) you could use the AddAvailableContentType method.


I have adjusted the earlier shared example and added that step as well.

 

URI

_api/web/lists/getbyTitle('@{variables('ListName')}')/contenttypes/AddAvailableContentType

 

Headers

{
  "Accept": "application/json;odata=verbose",
  "Content-Type": "application/json;odata=verbose"
}

 

Body

{
"contentTypeId" : "@{variables('ContentTypeId')}"
}

 

addavailablecontenttype_method.png

 

 

 

 



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #MicrosoftCopilotStudio content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


This still works? I find a lot of posts online saying this doesn't work anymore.

It keeps retrying 😕

MatthiasVeelaer_0-1688473361018.png

This is what my current flow looks like:

MatthiasVeelaer_1-1688473414988.png

 

Expiscornovus
Most Valuable Professional
Most Valuable Professional

Hi @MatthiasVeelaer,

 

What are you using in the ListID variable? The name of the variable suggests you are using a GUID or id.

 

The getbytitle method however expects the title/name of the library or list. 

 

In my case the name of my library was called 'Enable CTs'. In that case the Uri should be:

 

_api/web/lists/getbyTitle('Enable CTs')

 



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #MicrosoftCopilotStudio content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


Yeah sorry, the name does indeed suggest that but I just forgot to rename the variable. It is a string 🙂

MatthiasVeelaer_0-1688473780814.png

There I changed it 🙂

Expiscornovus
Most Valuable Professional
Most Valuable Professional

Hi @MatthiasVeelaer,

 

Can you also remove that AllowContentTypes from your first request. That property is not something you can set/update.

 

You can only update the ContentTypesEnabled property. Also see my example. I am not using the AllowContentTypes property in my payload.

 

And Yes, it should work. I just tested this flow in my own development environment and both the setting was enabled and the content type was added 😁



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #MicrosoftCopilotStudio content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


Alright! I will remove that. I will take another look at it and see whether or not I have made a mistake somewhere. Let's hope I missed something 😄

Expiscornovus
Most Valuable Professional
Most Valuable Professional

Hi @MatthiasVeelaer,

 

I had another look at your last screenshot and specifically the URI of your second request. I noticed a potential space character in the middle.

 

Can you also make sure there is no accidental typo/space character in the uri. Specifically between the /contenttypes and the listtitle variable?

 

Below is an example typo gif (click on it to see it in higher resolution).

 

typoinuri.gif



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #MicrosoftCopilotStudio content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


Yeah I noticed that too as difference in our screens however there doesn't seem to be a space there 😞

 

Expiscornovus
Most Valuable Professional
Most Valuable Professional

Hi @MatthiasVeelaer,


Thanks for checking.

 

Can you also double check that the content type you are trying to add already exists in your test site?

 

You can check this in the site settings > Web Designer Galleries > Site content types or directly navigate to this type of link (replace contoso and yoursitename by your specific values) :

https://contoso.sharepoint.com/sites/yoursitename/_layouts/15/SiteAdmin.aspx#/contentTypes

 

The AddAvailableContentType method only works if the content type is already available. 

contentTypeId: Specifies the identifier of the content type to be added to the content type collection. It MUST exist in the web's available content types.

https://learn.microsoft.com/en-us/openspecs/sharepoint_protocols/ms-csomspt/6d9692cd-56e5-4d5f-aec9-...

 

Looking at the contenttypeId you are trying to add a custom Document content type which has Document (0x0101) as a parent, is that correct?



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #MicrosoftCopilotStudio content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


Yes correct, it has Document as parent type. Content type is available on the site.

This is what I got a second ago. Think something might be wrong with the connection?

MatthiasVeelaer_0-1688477102280.png

 

Expiscornovus
Most Valuable Professional
Most Valuable Professional

Hi @MatthiasVeelaer,

 

Can you share screenshots of the configuration you used in your last test and a screenshot of the last failed flow instance (with both HTTP request actions expanded) and also share the specific error you are seeing?

 

I also assume you already checked the library settings of your test library and made sure that the content type is not already added? If it is already added and you try to rerun the same flow again, it will fail the second time with a BadGateway.



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #MicrosoftCopilotStudio content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


Expiscornovus
Most Valuable Professional
Most Valuable Professional

Hi @MatthiasVeelaer,

 

Can you please check if you see an innererror message in the body of the failed action?

 

Like in my example below, a HTTP 502 BadGateway can be caused if the content type is already added the the target library.

 

It would be useful for troubleshooting to see if you get the same or a different type of error message in the body?

 

innererror_message.png



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #MicrosoftCopilotStudio content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


Hi There, 

 

Use this solution - 

 

Sure, here's how you can change the "Allow management of content types" setting on an existing SharePoint library and then add a custom content type to it using Power Automate.

To enable content type management:

1. Begin by creating a new flow. Add an appropriate trigger based on your needs. For manual testing, you can use "Manually trigger a flow".

2. Next, add the "Send an HTTP request to SharePoint" action. This action will allow you to call the SharePoint API to modify the library settings.

3. Fill in the required fields for the action as follows:

- Site Address: (Your SharePoint site URL)
- Method: POST
- Uri: _api/web/lists/getbytitle('Your Library Name')
- Headers:
- Accept: application/json;odata=nometadata
- Content-Type: application/json;odata=nometadata
- If-Match: *
- X-HTTP-Method: MERGE
- Body:

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

4. Save and run the flow.

To add a custom content type:

1. You need the ID of the content type you wish to add. If you don't have it, you can get it using another HTTP request action. For the Uri field, use `_api/web/AvailableContentTypes?$filter=Name eq 'Your Content Type Name'` and select the ID from the response.

2. Add another "Send an HTTP request to SharePoint" action to your flow.

3. Configure the action as follows:

- Site Address: (Your SharePoint site URL)
- Method: POST
- Uri: _api/web/lists/getbytitle('Your Library Name')/ContentTypes/AddAvailableContentType
- Headers:
- Accept: application/json;odata=nometadata
- Content-Type: application/json;odata=nometadata
- Body:

```json
{
"contentTypeId": "Your Content Type ID"
}
```

4. Save and run the flow again.

Remember to replace "Your Library Name", "Your Content Type Name", and "Your Content Type ID" with the actual names and ID from your SharePoint site.

This method should work to enable content type management for an existing SharePoint library and add a custom content type to it using Power Automate. Note that you need the necessary permissions to modify library settings and add content types in SharePoint.

 

Please mark as solution if this helps and give me kudos. 

 

Thanks, 

Sandeep

 

Ok so it does however seem that when I search for the content type using the sharepoint get request it gives back nothing but when I search for a content type that is actually on the site then I do get response.

 

However when I use the admin center I can see the content type in the available ones for the website with this message above:

MatthiasVeelaer_0-1688506367992.png

So I guess it still isn't actually on the site so how would I go about actually adding it so that it can be used?

Expiscornovus
Most Valuable Professional
Most Valuable Professional

Hi @MatthiasVeelaer,

 

There should be a publish option on the content type in the content type gallery which you can use to either publish it or re-publish it (if needed).

https://learn.microsoft.com/en-us/sharepoint/publish-content-type

 



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #MicrosoftCopilotStudio content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!    This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Community MembersNumber SolutionsSuper UsersNumber Solutions Deenuji 9 @NathanAlvares24  17 @Anil_g  7 @ManishSolanki  13 @eetuRobo  5 @David_MA  10 @VishnuReddy1997  5 @SpongYe  9JhonatanOB19932 (tie) @Nived_Nambiar  8 @maltie  2 (tie)   @PA-Noob  2 (tie)   @LukeMcG  2 (tie)   @tgut03  2 (tie)       Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 2: Community MembersSolutionsSuper UsersSolutionsPower Automate  @Deenuji  12@ManishSolanki 19 @Anil_g  10 @NathanAlvares24  17 @VishnuReddy1997  6 @Expiscornovus  10 @Tjan  5 @Nived_Nambiar  10 @eetuRobo  3 @SudeepGhatakNZ 8     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 3:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji32ManishSolanki55VishnuReddy199724NathanAlvares2444Anil_g22SudeepGhatakNZ40eetuRobo18Nived_Nambiar28Tjan8David_MA22   Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 4:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji11FLMike31Sayan11ManishSolanki16VishnuReddy199710creativeopinion14Akshansh-Sharma3SudeepGhatakNZ7claudiovc2CFernandes5 misc2Nived_Nambiar5 Usernametwice232rzaneti5 eetuRobo2   Anil_g2   SharonS2  

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (579)