Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Unanswered

How to grant a user to SCA (primary admin)

(0) ShareShare
ReportReport
Posted on by

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:

raphaglr_0-1686059614354.png

 

 

 

{
"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!

 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Michael Gernaey – Community Spotlight

We are honored to recognize Michael Gernaey as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 566 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 516 Super User 2025 Season 1

#3
stampcoin Profile Picture

stampcoin 492