Skip to main content
Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Answered

Remove user from SharePoint Group using REST

(0) ShareShare
ReportReport
Posted on by 59

Hi Huys,

 

I'm currently building two flows linked to a PowerApp that manages Sharepoint Groups memberships on a single site collection.

So i've got one flow to add users to sharepoint groups, it works fine.

I also have one other flow that deletes users from SharePoint and it's driving me crazy.

 

I made a copy paste of the action to add user to the group and modified the URI section to add "RemoveByLoginName"

 

 

1.png

 

And it's not working, i have this error :

 

 

 

 

 

The parameter 'LoginName' in the request payload is not a valid parameter for the function import 'RemoveByLoginName'

 

 

 

 

 

So i tried to put the "Body" (Corps) section directly in the URI section

 

 

 

 

_api/web/sitegroups('355')/users/RemoveByLoginName("i:0#.f|membership|y.******@******.com")

 

 

 

 

 

Not working either and it's giving me this error

 

 

 

 

"The expression \"web/sitegroups('355')/users/RemoveByLoginName(\"i:0\" is not valid.

 

 

 

 

 

So i made another shot and tried to just put the UPN like that 

 

 

 

 

_api/web/sitegroups('355')/users/RemoveByLoginName('y.******@******.com')

 

 

 

 

 

And nope, doesn't work, i have this error 

 

 

 

 

The user does not exist or is not unique.

 

 

 

 

 

Anyone has a clue about what's wrong ?

 

Thanks,

Regards, 

  • Community Power Platform Member Profile Picture
    on at
    Re: Remove user from SharePoint Group using REST

    The solution is to url-encode the claim (the whole string starting with 'i:0#.f|...').

     

    instead of 

    _api/web/sitegroups('355')/users/RemoveByLoginName("i:0#.f|membership|y.******@******.com")

    you need to put the claim inside a encodeUriComponent() expression, so that it looks like this:

    SPO-REST-RemoveByLoginName-PowerAutomate.png

     

     

    See also here https://learn.microsoft.com/en-us/previous-versions/office/developer/sharepoint-rest-reference/dn531432(v=office.15)?redirectedfrom=MSDN#endpoint-uri-7

     

  • petrinnn Profile Picture
    18 on at
    Re: Remove user from SharePoint Group using REST

    Hi @kokoloco , can u help me?

     

    Im trying to remove some user from a SharepointGroup (Visitors, Id 70).

     

    I tried follow your steps, but..  i cant know:

     

    What is: xGroupPermiss...?

    What is: xUserID?

     

    When i add some user, i used this uri:

    /_api/web/sitegroups/GetById(70)

     

    As you can see, i didnt put nothing after sitegroups, but you did. What is this xGroupPermiss, the Id of the group or of the site? If is the site, where should i write the if of the group.

     

    And about the xUserID is just the email : "daniel@aa.com" or should i write another thinks?

     

    I tryed this, but didnt works:

     

    petrinnn_0-1652812095698.png

     

  • kokoloco Profile Picture
    3 on at
    Re: Remove user from SharePoint Group using REST

    Untitleds.png

  • DMCTechnology Profile Picture
    4 on at
    Re: Remove user from SharePoint Group using REST

    Could you post a screenshot of your final REST settings that worked? Thanks!

  • SandeepSP Profile Picture
    2 on at
    Re: Remove user from SharePoint Group using REST

    Can you please help me in writing the REST API to get the sharepoint user id ? Because I am facing similar issue. I am trying to delete a user from sharepoint group. When I use RemoveById I am getting the error:cannot convert a primitive value to the expected type 'edm.int32'.

     

     

  • Verified answer
    LaurentH Profile Picture
    59 on at
    Re: Remove user from SharePoint Group using REST

    Ok nevermind,

     

    Finally i'm using REST to get the SharePoint ID of the user using his UPN / email, and i've replaced the RemoveByLoginName by RemoveByID and it's working as expected.

     

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June 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 497 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 1

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 1