In Microsoft flow there is no built in action to add a user to a SharePoint group. One way to achieve this is to use the “Send HTTP request to SharePoint”
in this action you need to
- Set the URL of the Site
- Set method to “POST”
- URI set to “_api/web/sitegroups({GROUPID})/users”, example: _api/web/sitegroups(10)/users
- Add header with key=”accept” and value = “application/json;odata.metadata=none”
- Add header with key =”content-type” and value = “application/json”
- Set the Body to be {‘LoginName’:’i:0#.f|membership|[EMAIL ADDRESS]’}, example: {‘LoginName’:’i:0#.f|membership|john.doe@domain.onmicrosoft.com’}
It would look like this
This is tested with a SharePoint online connection but assume might work with on premise SharePoint as well.
Just a note here, because your blog doesn’t use unicode, people cannot cut and paste the “Body” above into Flow. The apostrophes are not actual apostrophes. You’ll need to change them to ” ‘ ” to get this to work.
Can i add wildcards to this? I want to add any user that has 123.com at the end of their username to a specific group
How HTTP request can be modified in order to _remove_ users from group instead of adding?