Hello,
I'm looking to automate grant access to a service account in the Primary Admin role on Sharepoint when I apply a template (site script).
For this I have created a Power Automate which is triggered by HTTP and follows exactly this process:
here.
I also took care to add my service account as Owner via my script and it does indeed have the SharePoint Admin role in Azure.
However, I get an error on my last rest api to Sharepoint action:
{
"error": {
"code": 502,
"source": "flow-xxx.azure-apim.net",
"clientRequestId": "8f75f0b4-0xxxx597fc8421e8",
"message": "BadGateway",
"innerError": {
"status": 502,
"message": "You must be a site collection administrator to set this property.\r\nclientRequestId: 8f75f0xxx9b-8bf7-f597fc8421e8\r\nserviceRequestId: b82fbaa0-101dxxxx92ebdd872",
"source": "https://XXXXX.sharepoint.com/sites/ZZZZZ/_api/web/getuserbyid(11)",
"errors": [
"-2146232832",
"Microsoft.SharePoint.SPException"
]
}
}
}
Can you give me a tip on how to do this?
Thanks in advance!
Michael E. Gernaey
566
Super User 2025 Season 1
David_MA
516
Super User 2025 Season 1
stampcoin
492