web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Flow for setting up it...
Power Automate
Unanswered

Flow for setting up item permission over REST API

(0) ShareShare
ReportReport
Posted on by 4

I would like to use flow to set item permission based on multiple metadata.

everything works ok but inside apply to each i get values inside square brackets and that's why i get an error.

 

The expression "lists/getByTitle('Enterprise')/items(['284'])/roleassignments/addroleassignment(principalid=['132'],roledefid=1073741826)" is not valid.
clientRequestId: 11a0d4e2-9c13-41a1-a222-797f3193c689
serviceRequestId: 01d6f39f-8048-c000-89d5-8857e0799846

 

How to enter that without brackets. Ideas please 😄

Categories:
I have the same question (0)
  • Expiscornovus Profile Picture
    33,175 Most Valuable Professional on at
    Re: Flow for setting up item permission over REST API

    Hi @Ziby,

     

    In your example the Uri would be:

    _api/web/lists/getByTitle('Enterprise')/items(284)/roleassignments/addroleassignment(principalid=132,roledefid=1073741826)

     

    Below is an example of such a setup in a Send an HTTP request to SharePoint action. 

    Keep in mind that this only works if inheritance is already broken on the item and it already got unique permissions.

     

    addroleassignment_example.png

  • Ziby Profile Picture
    4 on at
    Re: Flow for setting up item permission over REST API

    Sorry i will try to explain that a little bit more 😄

     

    So we have Sharepoint document library with column "product". Type is choice and we allow multiple selection.
    we also have Sharepoint groups with exactly the same names as the product field values.

     

    I created flow which starts when istem is created, then it clears permission on item

    Power automate1.png

    Since we use multiple selection i can use only Apply to each.

    Power automate4.png

    And after test i get an error

     

    The expression "lists/getByTitle('Enterprise')/items(['284'])/roleassignments/addroleassignment(principalid=['132'],roledefid=1073741826)" is not valid.
    clientRequestId: 44c91033-1c4c-4535-9fee-54e082a0761b
    serviceRequestId: b8daf39f-509a-c000-5e6c-afe2edeb61b9

     

    The cause for that error is that the values ItemID and GroupID are in Square Brackets and REST api 
    do not allow such values.

     

    Do you have some idea how set that without brackets

     

    Thanks

  • Verified answer
    Expiscornovus Profile Picture
    33,175 Most Valuable Professional on at
    Re: Flow for setting up item permission over REST API

    Hi @Ziby,

     

    Even with your setup you shouldn't need to put brackets around the ItemID and GroupID variables. They are just numbers, the REST API should be able to handle those without the [' '].

     

    So, in your setup it would be like this. Can you try this instead?

     

    _api/web/lists/getbytitle('Enterprise')/items(@{variables('ItemID')})/roleassignments/addroleassignment(principalid=@{variables('GroupID')},roledefid=1073741826)

     

    withoutbrackets.png

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 462 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 456 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard