cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
TP3_Altice
Frequent Visitor

Set permissions for a library folder (Not an ITEM in the library)

I have 30-40 sharepoint library files and I need a way to bulk set permissions on them based on a sharepoint group. Ex, in pictures:

 

When I click Manage access,

flow2.jpg

I want to give access to just this group but I have to go through every single other group manually. So for ALL of these, of course that’s a TON of clicks. I figure if I can use the API to do this I’ll save a ton of time, learn something I can use in the future and eliminate a lot of possible mistakes. Everything I see on the google machine is about providing access to LISTS so I’m getting lost trying to find how to get to the actual folder itself. Luckily, I’m actually creating the folders in a flow so I think if I can capture the information there and do it right after I create it, that’s the secret.

Here’s what I’ve come up with so far…I wrote in an HTTP GET request just to see if I could get to the folder. I succeeded there by using :

flow3.jpg

 

This process fine and I get a response that shows me the folder I’m looking for:

flow4.jpg

But here’s where I am lost. I don’t know what to DO with it. I found something on the Google box that said I could clear all permissions with “/breakroleinheritance(copyRoleAssignments=false,clearSubscopes=true)” after the API call. So I tried it:

 

flow5.jpg

So this error says it cant find the resource. So…rats. Any suggestions I could try?

 

 

4 REPLIES 4
UdayAdhikari
Most Valuable Professional
Most Valuable Professional

In SharePoint, folder is an item so you should be able to break inheritance with HTTP Request Post action in flow.

 

Try below first on a browser by replacing SiteUrl, LibName and FolderName with your site info - please note, SiteUrl includes up to sub-site if you have one.

https://{siteurl}/_api/Web/GetFolderByServerRelativeUrl('{LibName}\{FolderName}')

Example:

https://abc.sharepoint.com/sites/DemoApps/_api/Web/GetFolderByServerRelativeUrl('ProfilePictures/Dec...

 

Once you get above URL to return data in browser simply construct the URL in HTTP Post Action in flow and see if it resolves the issue.

Thanks for the suggestion, Uday, but the same thing happens here. I am able to GET to the folder just fine. Like,if instead of a "POST" I just try to GET the name of the folder, I can do that and store it off just fine.

 

working.jpg

The issue at hand is how do I take action on the folder? Can I clear the permissions and add new ones? Here is the solution that works on a LIST:

https://www.portiva.nl/nl/portiblog/2019/10/21/set-list-item-level-permissions-in-sharepoint-using-f... 

fchopo
Super User
Super User

Hello @TP3_Altice 

In this post you will find a similar question, and a very helpful answer by @abm : https://powerusers.microsoft.com/t5/Building-Flows/How-do-I-add-permissions-to-folder-after-it-is-cr...

You should use this expression to break role inheritance: 

_api/Web/GetFolderByServerRelativeUrl('{documentlibraryname}/{foldername}')/ListItemAllFields/breakroleinheritance(copyRoleAssignments=true, clearSubscopes=true)

By the expression you shared, you should use the following:

_api/Web/GetFolderByServerRelativeUrl('Invoices/Altice%20East')/ListItemAllFields/breakroleinheritance(copyRoleAssignments=true, clearSubscopes=true)

Hope it helps!

Ferran

 

 

Did I answer your question? Please consider to mark my post as a solution to help others.
Proud to be a Flownaut!
UdayAdhikari
Most Valuable Professional
Most Valuable Professional

@TP3_Altice - this is what I had to do, hope this helps. (slightly different than what I initially suggested). I also included an option for user, not just SP Group.

 
 

Grant SP Group access to a folder in SharePointGrant SP Group access to a folder in SharePoint

 

Helpful resources

Announcements

Check out the Copilot Studio Cookbook today!

We are excited to announce our new Copilot Cookbook Gallery in the Copilot Studio Community. We can't wait for you to share your expertise and your experience!    Join us for an amazing opportunity where you'll be one of the first to contribute to the Copilot Cookbook—your ultimate guide to mastering Microsoft Copilot. Whether you're seeking inspiration or grappling with a challenge while crafting apps, you probably already know that Copilot Cookbook is your reliable assistant, offering a wealth of tips and tricks at your fingertips--and we want you to add your expertise. What can you "cook" up?   Click this link to get started: https://aka.ms/CS_Copilot_Cookbook_Gallery   Don't miss out on this exclusive opportunity to be one of the first in the Community to share your app creation journey with Copilot. We'll be announcing a Cookbook Challenge very soon and want to make sure you one of the first "cooks" in the kitchen.   Don't miss your moment--start submitting in the Copilot Cookbook Gallery today!     Thank you,  Engagement Team

Tuesday Tip | How to Report Spam in Our Community

It's time for another TUESDAY TIPS, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.   As our community family expands each week, we revisit our essential tools, tips, and tricks to ensure you’re well-versed in the community’s pulse. Keep an eye on the News & Announcements for your weekly Tuesday Tips—you never know what you may learn!   Today's Tip: How to Report Spam in Our Community We strive to maintain a professional and helpful community, and part of that effort involves keeping our platform free of spam. If you encounter a post that you believe is spam, please follow these steps to report it: Locate the Post: Find the post in question within the community.Kebab Menu: Click on the "Kebab" menu | 3 Dots, on the top right of the post.Report Inappropriate Content: Select "Report Inappropriate Content" from the menu.Submit Report: Fill out any necessary details on the form and submit your report.   Our community team will review the report and take appropriate action to ensure our community remains a valuable resource for everyone.   Thank you for helping us keep the community clean and useful!

Users online (3,415)