[Solved] Attempted to perform an unauthorized operation in Power Automate

Recently, while working on a Power Automate solution for one of my clients, I had to create various types of SharePoint sites, including Communication Sites, Group-connected Team Sites, and Non-group-connected Team Sites, using the REST API. After creating the sites, the requirement was to assign Owners, Members, and Visitors automatically.

Everything was fine until I tried to get the Group ID of the newly created site. At that point, Power Automate threw an error:

Attempted to perform an unauthorized operation
Attempted to perform an unauthorized operation in Power Automate

In this tutorial, I will explain why this error happens and how you can fix it dynamically in Power Automate

[Error] Attempted to perform an unauthorized operation

This error appears because Power Automate is trying to perform an action on SharePoint without having the required permissions.

In my case, after creating the site using the REST API, the next step was to retrieve the Group ID of the site.

But here’s the problem:

You won’t see this error every time. It only happens in specific situations. When we create the site, we usually add an owner to that site. If the same owner’s credentials are used in the “Send an HTTP request to SharePoint” action, everything works fine.

However, if the site owner and the connection in Power Automate are different users, the flow does not get the required permission to read the site details. That’s when SharePoint throws the error:

Attempted to perform an unauthorized operation

In my case, the issue occurred due to a permission mismatch. When the site was created, I assigned Lidia as the Site Owner:

Attempted to perform an unauthorized operation

However, when I tried to retrieve the Group ID, the Power Automate connection was running under my account (Asit) instead of Lidia’s:

Attempted to perform an unauthorized operation error

Since Asit was not the site owner, SharePoint blocked the request, which caused the error.

Fix: Attempted to perform an unauthorized operation

To fix this issue, you must ensure that the connection used in the ‘Send an HTTP request to SharePoint’ action has the required permissions on the newly created site.

There are two ways to solve this:

Option 1: Use the Same Account as the Site Owner

The simple way to fix this is to run the flow using the same user account that was added as the Site Owner during site creation.

For example:

  • If Lidia is assigned as the site owner
  • Then the SharePoint connection inside Power Automate must also run as Lidia
Fix Attempted to perform an unauthorized operation

This ensures that the HTTP request has full permissions to access the site and retrieve the Group ID.

Option 2: Manually add the Group ID

Suppose your flow still fails because the connection user does not have permission to read the site’s Group ID. In that case, you can avoid the error by manually assigning the correct Group IDs rather than retrieving them via the REST API.

Every SharePoint site connected to a Microsoft 365 Group uses three standard roles:

  • Owners Group – 3
  • Members Group – 5
  • Visitors Group – 4

So, instead of fetching the Group ID dynamically, you can build it manually using the site’s base URL.

To add a user to a specific SharePoint group, use the following URI format:

/_api/web/sitegroups/getById(GROUP_ID)/users

Replace GROUP_ID with the appropriate value:

  • Owners Group -> 3
  • Members Group -> 5
  • Visitors Group -> 4
Manually add the Group ID in Power automate

This completely bypasses the permission issue and works consistently, even if the connection user is different.

This error happens when the user running the flow does not have permission on the new SharePoint site. If the site owner and the Power Automate connection user are different, SharePoint blocks the request.

You can fix it by using the same account as the site owner or by manually using the group IDs (3, 5, 4) to add users without needing to fetch them from the API.

Also, you may like the following tutorials:

Power Apps functions free pdf

30 Power Apps Functions

This free guide walks you through the 30 most-used Power Apps functions with real business examples, exact syntax, and results you can see.

Download User registration canvas app

DOWNLOAD USER REGISTRATION POWER APPS CANVAS APP

Download a fully functional Power Apps Canvas App (with Power Automate): User Registration App