In this Power Automate tutorial, we will see how to fix the error ‘Cannot find a resource for the request addroleassignhments‘. Also, we will see how we get this error and how we can fix It.
Recently, when we are creating a SharePoint group using Power Automate rest API from the SharePoint list. After that, we added members and provided permission for that particular SharePoint group.
You can see the below screenshot of the SharePoint list named ‘SharePoint group’:
We encountered an error while assigning permission: ‘Cannot find the resource for the request addroleassignhments‘.This error states that the API endpoint, we are using does not support the operation we are performing i.e. providing permission to the SharePoint group.
Now we will discuss the solution, and how to solve the error when the resources cannot find for the request addroleassignments.
Cannot find the resource for the request addroleassignhments error in Power automate
Here we are creating an item in the SharePoint list and my SharePoint list contains the below columns:
- Group Name (Title) -Single line of Text
- Members: Person
- Description: Multiple lines of text
- Group Permission: Choice
Then the flow will trigger every time a new item is created on that list. And then it will perform the below task:
- Create a SharePoint group: In the below screenshot, you can see after adding the trigger action ‘When an item is created’ we have created a ‘Send an HTTP request to SharePoint’ action. That will create a SharePoint group on the SharePoint site.
- Add members to SharePoint group: To add members to the SharePoint group we fetched the group id using Compose action. Then we add members to the group using the group id in the ‘Send an HTTP request to SharePoint’ action. As we are adding multiple members, it will add Apply to each action.
- Provide Permission to the SharePoint group: To provide permission to the SharePoint group, we need a group id, also a role definition id.
To get the role definition id, we will ‘ Send an HTTP request to SharePoint’ action. From the output, we will get the role definition id using Compose action.
Then we will provide the permission to the SharePoint group using ‘Send an HTTP request to SharePoint’
However, when we were running this flow, we came across this error- Cannot find the resource for the request addroleassignhments‘ error in Power Automate. You can also refer to the image given below for a detailed error message.
Now, in the next part, we will see how we can solve this error in Power Automate.
Cannot find the resource for the request addroleassignhments error in Power Automate – Solution
Here we will first understand why we are getting an error: Cannot find the resource for the request addroleassignhments in Power Automate.
Now, if you look closely at the last step where we are adding permission to the SharePoint group, we specified below the ‘Uri’ field in the ‘Send an HTTP request to SharePoint’ action.
/_api/web/roleassignments/addroleassignments(principalid=@{outputs('Compose_-group_id')}, roledefId=@{outputs('Compose-role_id_')})
Here we provide the method as addroleassignments(), also we are passing two parameters i.e. principalid and roledefId. However, this method and the parameter we passed are not correct.
So it should not be ‘addroleassignments()’, it should be ‘addroleassignment()‘. Additionally, the parameter names principalid and roledefid were changed to principalid and roleDefId, respectively.
So the correct Uri is below:
/_api/web/roleassignments/addroleassignment(principalid=@{outputs('Compose_-group_id')}, roleDefId=@{outputs('Compose-role_id_')})
This is how we can fix the error ‘Cannot find the resource for the request addroleassignhments’ in Power Automate’.
Conclusion
In this Power Automate tutorial, we saw how we can fix the error: ‘Cannot find the resource for the request addroleassignhments’ in Power Automate.
You may also like:
- Search in SharePoint List in Power Automate
- Add Comments to SharePoint list items using Power Automate
- Create Content Type in SharePoint using Power Automate
- How to loop through SharePoint list items in Power Automate
After working for more than 15 years in Microsoft technologies like SharePoint, Office 365, and Power Platform (Power Apps, Power Automate, and Power BI), I thought will share my SharePoint expertise knowledge with the world. Our audiences are from the United States, Canada, the United Kingdom, Australia, New Zealand, etc. For my expertise knowledge and SharePoint tutorials, Microsoft has been awarded a Microsoft SharePoint MVP (9 times). I have also worked in companies like HP, TCS, KPIT, etc.