Hallo, it's second day without solution :( .... helppp !
My need is grant access to a list in my sharepoint 365 space for users not always registered in my site. So the idea is a list where I insert their name ( as users() of a sharepoint list ) and an automation (triggered by insert) set custom grant with the desired role in the list. I followed this article:
https://community.powerplatform.com/blogs/post/?postid=9d3d2a51-71ee-4ca5-9de7-122804a65770 that primary says to break
inheritance and later set permission into the list.
More this I see that if the user never access to the site, can be a problem retrive the principalID, so I found this:
POST http://<sitecollection>/<site>/_api/web/ensureUser(logonName)
in order to set the principalID even i f the user never access on my site.
So the flow is like this:
0. trigger new row in the user list
1. retrive new user principal ID by ensureUser
2. break inheritance
3. set user grant with role on the list
The first part, trigger to start job, retrive user info and break inheritance seems work fine, the problem @ #3 when I launch the http request, the flow stops with error:
Value does not fall within the expected range. clientRequestId: 09448e45-dfac-4433-bbe2-a1f235d33558 serviceRequestId: 25b644a1-f045-9000-866e-04efeacf0a60
Here the log:
{
"dataset": "https://enelcom.sharepoint.com/sites/COLLAUDO",
"parameters/method": "POST",
"parameters/uri": "_api/lists/getByTitle('target list')/roleassignments/addroleassignment(principalid=26,roledefid=1073741827)"
}
{
"status": 400,
"message": "Value does not fall within the expected range.\r\nclientRequestId: 09448e45-dfac-4433-bbe2-a1f235d33558\r\nserviceRequestId: 25b644a1-f045-9000-866e-04efeacf0a60",
"source": "https://enelcom.sharepoint.com/sites/COLLAUDO/_api/lists/getByTitle('target%20list')/roleassignments/addroleassignment(principalid=26,roledefid=1073741827)",
"errors": [
"-2147024809",
"System.ArgumentException"
]
}
Any idea or suggestion?
Thanks!
Stefano