
Announcements
Hello,
Is it possilble to move a person from one SP user group to another user group.
Lets say a user is in a "Read" only group but the manger wants to put them in a "Contributor" group?
This would need to be automated using REST.
A manager would input the instruction on a SP list form triggering the workflow to do the heavy lifting.
Hi, @golfnutt82 , I appreciate that you may have legacy SP groups and users, and there's definitely ways there too ... but have you looked at the Office 365 Groups actions?
If the users are all 365 groups members (which all modern SP / Teams groups are) then you can accomplish what you want using the "Remove member from group" and "Add member to group" actions therein.
I appreciate that you mentioned that you would like this to react to changes made by a manager on a SharePoint list's form input (that's just going to be a new/amended SP list trigger if that's it) but then you also said that you wanted this to be REST, too.
So if you *also* want to make this REST compatible, after testing it using a flow button or reacting to test entries on the list in question, you can change the trigger to an HTTP Request. For which you'll need to feed it the right input. But once you have that it will mean that you can then have a separate flow that simply calls the HTTP Request.
Responses can also be added for even more full REST compatibility.
However, like I say, if you just want it to react to the input on a SharePoint list, then make the trigger one of either SharePoint triggers "When an item is created" or "When an item is created or modified" and it'll fire accordingly.
EDIT - The following questions are important to discern if you're doing this for the user groups defined in SP Sites:
If the answer to that third question is "yes" I'm sure someone around here might be kind enough to help do the whole thing for you. However, and I say this with kindness, you will almost definitely be more rewarded finding someone in your company that could build this for you. As there is almost definitely someone doing a low level job that could.
Still, if you just wish to add and remove users to and from a group with HTTP calls, use the setups below, where:
| _GROUP_ID_ | = | The Id of the SP.Group user group |
| _USER_LOGINNAME_ | = | The LoginName of the SP.User user |
| _USER_EMAILADDR_ | = | The Email of the SP.User user |
To add a user:
| Method | POST | ||||||||
| URI | /_api/web/sitegroups/GetById("_GROUP_ID_")/users | ||||||||
| Headers |
| ||||||||
| BODY | { "__metadata": { "type": "SP.User" }, "LoginName": "_USER_LOGINNAME_" } |
To remove a user:
| Method | POST | ||||||||||||
| URI | /_api/web/sitegroups/GetById("_GROUP_ID_")/users/getbyemail('_USER_EMAILADDR_') | ||||||||||||
| Headers |
| ||||||||||||
| BODY |
If you want to do any more, I would suggest perhaps reading the SharePoint REST documentation online, there is quite a bit, there is also the Graph docs, too.
To be completely honest with you, that's how I have provided the above, along with some internet searching based on that.