cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
TP3_Altice
Level: Powered On

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
Level: Powered On

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

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.

TP3_Altice
Level: Powered On

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

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
Level 10

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

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

 

 

UdayAdhikari
Level: Powered On

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

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

 
 

SPApplyPermisisonAtFolderLevel.pngGrant SP Group access to a folder in SharePoint

 

Helpful resources

Announcements
firstImage

New Ranks and Rank Icons in April

Read the announcement for more information!

firstImage

Better Together Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Community Summit North America

The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (5,051)