0

Having trouble with adding or removing Role Assignments on SharePoint document folders using REST API through Power Automate.

Process is to copy a Template folder with subfolders. Of which, 2 subfolders need unique permissions to prevent unwanted user access.

I believe BreakRoleInheritance is being broken properly prior Sent POST via Send HTTP request via SharePoint:

_api/web/GetFolderByServerRelativeUrl('Shared Documents/SHOW FOLDERS/2017 Budgets/01 January/SHOW20')/ListItemAllFields/breakroleinheritance(copyRoleAssignments=true,clearSubscopes=true)

Sample command sending DELETE via HTTP to remove a SP Group with ID of (6) from folder:

_api/web/GetFolderByServerRelativeUrl(‘Shared Documents/SHOW FOLDERS/2017 Budgets/01 January/SHOW20')/ListItemAllFields/roleassignments/getbyprincipalid(6)

Error output:

{
  "status": 400,
  "message": "The expression \"web/GetFolderByServerRelativeUrl(‘Shared Documents/SHOW FOLDERS/2017 Budgets/01 January/SHOW20')/ListItemAllFields/roleassignments/getbyprincipalid(6)\" is not valid.\r\nclientRequestId: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\r\nserviceRequestId: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\",
  "source": "https://xxxxxxxxx.sharepoint.com/sites/FILETRANSFER/_api/web/GetFolderByServerRelativeUrl(%E2%80%98Shared%20Documents/SHOW%20FOLDERS/2017%20Budgets/01%20January/SHOW20')/ListItemAllFields/roleassignments/getbyprincipalid(6)",
  "errors": [
    "-1",
    "Microsoft.SharePoint.Client.InvalidClientQueryException"
  ]
}
2
  • Fixed my issue by fixing a typo. Must have did a cut and paste badly. Nov 23, 2020 at 17:51
  • On the DELETE command, the single quote before Shared Documents was the wrong character. Nov 23, 2020 at 20:09

1 Answer 1

0

The following worked for me.

  1. Break Inheritance for the folder:
method: POST, content-type:application/json;odata=verbose

_api/web/GetFolderByServerRelativeUrl('TestLibrary/2019')/ListItemAllFields/breakroleinheritance(copyRoleAssignments=true,clearSubscopes=true)
  1. Grant a SharePoint group with id=19 Contribution permission to the folder:
method: POST, content-type:application/json;odata=verbose

_api/web/GetFolderByServerRelativeUrl('TestLibrary/2019')/ListItemAllFields/roleassignments/addroleassignment(principalid=19,roledefid=1073741827)

roledefid for Permission Levels are as follows:

1073741829, Full Control

1073741827, Contribute

1073741826, Read

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.