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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Remove user from Share...
Power Automate
Unanswered

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, 

Categories:
I have the same question (0)
  • Verified answer
    LaurentH Profile Picture
    59 on at

    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.

     

  • SandeepSP Profile Picture
    2 on at

    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'.

     

     

  • DMCTechnology Profile Picture
    4 on at

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

  • kokoloco Profile Picture
    3 on at

    Untitleds.png

  • petrinnn Profile Picture
    18 on at

    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

     

  • Community Power Platform Member Profile Picture
    on at

    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

     

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 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard