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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / SharePoint remove user
Power Automate
Answered

SharePoint remove user

(0) ShareShare
ReportReport
Posted on by 89

Hello All,

 

I am trying to add and remove users to a SharePoint site using the "Send an HTTP request to SharePoint" action. The add action works but the removal does not.

 

Any ideas where I am going wrong?

stormin_30_0-1602972537420.pngstormin_30_1-1602972578698.png

Error message: The expression "web/SiteGroups(https:/normyoung.sharepoint.com/sites/SharePointDemo/_api/Web/SiteGroups/GetById(5))/users/removeByLoginName" is not valid.
clientRequestId: b2bf9405-1b0c-438e-80a5-c8d575776e18
serviceRequestId: a5ac849f-b04d-b000-cc44-463d26a3000d

Thanks.

 

Norm

 

Categories:
I have the same question (0)
  • ChrisPiasecki Profile Picture
    6,428 Most Valuable Professional on at

    Hi @stormin_30,

    Try adding the user login into the request string as such. 

    ..../removeByLoginName(@v)?@v='<USER CLAIMS>'  

    https://docs.microsoft.com/en-us/previous-versions/office/developer/sharepoint-rest-reference/dn531432(v=office.15)#removebyloginname-method-1

    ---

    Please click Accept as Solution if my post answered your question. This will help others find solutions to similar questions. If you like my post and/or find it helpful, please consider giving it a Thumbs Up.

  • stormin_30 Profile Picture
    89 on at

    Hi @ChrisPiasecki, thank you for the suggestion, I appreciate it. I was not able to get "removeByLoginName" to work and went with "removeById".

     

    It's working now and I will post the solution to help others.

     

    Norm

  • Verified answer
    stormin_30 Profile Picture
    89 on at

    Solution:

     

    Get user ID

    stormin_30_0-1603022558560.png

     

    Compose user ID

    stormin_30_1-1603022651221.png

    @{body('Send_an_HTTP_request_to_SharePoint_-_Get_User_Id')['d']['id']}

     

    Remove user

    stormin_30_2-1603022680013.png

     

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    The solution is to let the body empty and put everything in the URI, but url-encode the claim/login name (--> the whole string starting with 'i:0#.f|...').

     

    My SPO HTTP-REST-POST-Request looks like this:

     

    _api/web/sitegroups(@{variables('vSharePointGroupId')})/users/RemoveByLoginName('@{encodeUriComponent(items('Apply_to_each')?['AssignedTo/Claims'])}')

     

    See also this screenshot:

    SPO-REST-RemoveByLoginName-PowerAutomate.png

  • delicatebeing1 Profile Picture
    23 on at

    hello,

     I would like to receive your help that in my use case it takes forever to remove a user when I test it. Adding a user is too easy and direct, whereas removing is nearly impossible, there must be more details into that is not clearly mentioned in this post.

    delicatebeing1_0-1718028774843.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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Valantis Profile Picture

Valantis 377

#2
11manish Profile Picture

11manish 279

#3
David_MA Profile Picture

David_MA 234 Super User 2026 Season 1

Last 30 days Overall leaderboard