Add User to SharePoint Group

How to add a user to a single SharePoint Group in a SharePoint Online site collection using a Power Automate flow.

URI

Headers

Body

Screenshot with example

Sample data
SharePoint Group Name – Custom SharePoint Group
LoginName – i:0#.f|membership|jane@contoso.onmicrosoft.com

addusertosharepointgroup

Copy/paste example

Resources

SP.GroupCollection.getByName Method
SP.UserCollection object

That’s it, Happy testing!

You may also like...

2 Responses

  1. Martin says:

    Thanks for sharing!

    Will this generate a welcome email (as if you had added them through the UI by going to: site permissions > groups > add user)?

    Also, could you confirm how I would need to adapt this to remove a user from the group instead please? (I was looking for something like “/add” in the URI, which I could swap for “/remove” but couldn’t see anything like that).

    Thanks again!
    Martin

  2. Dennis says:

    Hi Martin,

    No, that won’t generate a welcome e-mail like in the interface.

    You can use a POST request with X-HTTP-Method DELETE in combination with the id of the user (via the getbyid method):
    _api/web/sitegroups/getbyname('Custom SharePoint Group')/users/getbyid(18)

    I will share this sample in a new blog later today.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.