Hi. I am relatively new to using REST operations, and I am at a loss as to how to remove a user from a SharePoint permissions group by using the Flow action "Send an HTTP Request to SharePoint."
I have a list of users--who are already provisioned in our SharePoint Online collection--that will be updated monthly with names of those requiring access and those leaving the department.
The list already exists, and I have been able to handle ADDING new users to the necessary groups; but I can't figure out how to (or even whether I can) remove users. Everything I've tried so far has ended with a "Missing required query string: @target..." error, or a more-basic JSON formatting error.
Here is my untrained attempt at configuring the REST action from Flow:
Help, please!!
(Thanks!)
Solved! Go to Solution.
Hi @mboonie,
May you try to use the Plumsail action Remove user from SharePoint Group to remove user from a group.
https://plumsail.com/docs/actions/v1.x/flow/how-tos/sharepoint/create-sp-group-add-users.html
Besides, I have seen a blog on how to remove users from a SharePoint Group in SPFx, please check the following link for more details:
Best regards,
Mabel
Got it!
I took a hard look at the "How to manage SharePoint Groups..." link above and was (apparently!) finally able to map the correct bits to the HTTP REST action. (Adding a user was much simpler, but that was probably because there was an explicit example of the correct Flow action elsewhere that I was able to leverage.)
So, to possibly save others from the same stress, here is a simplified version of the way I set up my Onboarding and Off-boarding flow:
Hi @mboonie,
May you try to use the Plumsail action Remove user from SharePoint Group to remove user from a group.
https://plumsail.com/docs/actions/v1.x/flow/how-tos/sharepoint/create-sp-group-add-users.html
Besides, I have seen a blog on how to remove users from a SharePoint Group in SPFx, please check the following link for more details:
Best regards,
Mabel
Unfortunately, my company has restricted the connectors/actions that we are allowed to use, and I am unable to register Plumsail apps and features.
I saw the other link earlier, but I had trouble understanding how to map the information in the article to the "Send HTTP to SharePoint" action. In particular, I'm not sure what to do with the content beginning with "let dataToPost = JSON.stringify(..." Do I put the whole thing in the "Body"? (I just tried that--substituting my userID variable for the login name--and received the all-too-familiar "Not well formatted JSON stream." message.)
Got it!
I took a hard look at the "How to manage SharePoint Groups..." link above and was (apparently!) finally able to map the correct bits to the HTTP REST action. (Adding a user was much simpler, but that was probably because there was an explicit example of the correct Flow action elsewhere that I was able to leverage.)
So, to possibly save others from the same stress, here is a simplified version of the way I set up my Onboarding and Off-boarding flow:
Hi Mboonie
I have try to do the same but i get error on removeByLoginName
If you look at either the "Headers" section of the INPUTS results (or the "Message" information in the output, which you pasted below), you'll see that there is a carriage-return getting encoded, resulting in a poorly-formed Headers input. (The carriage return is encoded as "\n" and ends up being sent as part of the header.) Thus, the header being sent is literally "application/json;\nodata=verbose", when it should be "application/json;odata=verbose".
Remove the carriage-returns and you'll likely resolve the problem.
-Boonie
Hi All,
just a note. I tried using the solution but kept on getting errors similar to previous highlighted. Found out if i was copy pasting any of the code parts then i would get an error. When i typed out the parts then the flow would work.
hope this helps.
Hello - Newbie here. I just wanted to know how to get the ID# in GetbyID in your Uri.
I don't know where in SharePoint site I will get the ID. Thanks in advance.
Please help. I got an error.
{
"message": "{\"odata.error\":{\"code\":\"-2130575276, Microsoft.SharePoint.SPException\",\"message\":{\"lang\":\"en-US\",\"value\":\"The user does not exist or is not unique.\"}}}\r\nclientRequestId: 31b44b28-73e5-4128-b224-620da891c1a9\r\nserviceRequestId: 59a2ea9e-f03d-0000-3fd8-97d38820f7fb",
"status": 404,
"source": "siteaddress/_api/Web/SiteGroups/GetByID(3)/Users/removeByLoginName",
"errors": []
}
not sure what is the format of loginName.
Hi, @Anonymous, and welcome.
You can get the ID/GUID of anything (lists, libraries, views, etc.) by going to it's Settings and checking the URL.
For example, if I select a list from my Site Contents and go to "List Settings" (click on the gear in the upper-right corner), you can find the list's ID in the URL that appears. For example: https://mycompany.sharepoint.com/teams/mySite/Outsourcing/_layouts/15/listedit.aspx?List=%7Bb91078c8-03ae-4289-be1d-2ecd29b3167d%7D
The ID itself is found after "List=". Some menus--and some browsers--display it differently. For example, it may appear encoded as "List=%7Bb91078c8%2D03ae%2D4289%2Dbe1d%2D2ecd29b3167d%7D" or decoded, as "List={B91078C8-03AE-4289-BE1D-2ECD29B3167D}" or even in-between, as "List=b91078c8%2D03ae%2D4289%2Dbe1d%2D2ecd29b3167d".
If it is encoded, you can certainly convert it manually (once you remember things like "%2D" is a hyphen, "%7B" is an opening curly brace, "%7D" is a closing curly brace, etc.). Or, you can use free online utilities like https://www.urlencoder.org/.
Generally, when providing an ID, you include the hyphens but not the surrounding curly braces. Thus, when prompted for an ID, the acceptable format is "B91078C8-03AE-4289-BE1D-2ECD29B3167D" (decoded, but without the curly braces.)
Note that there are some connectors where using the ID in place of selecting from the drop-down list of SharePoint Lists is a necessary "workaround." For example, the Get Items action displays your site's lists but not calendars. In these instances, selecting "Custom value" and then providing the item's ID is the only recourse.
Good luck... I hope this helps!
Ahh, I hate when that happens. That means that it was not able to resolve the email address. Usually this is because they aren't in the group from which you are trying to remove them.
A if/then simple check worked for me. I first set a variable to the email property of the user I'm working with. Then I check the length of the variable to determine whether the email of the user in question exists in the list. If there is no email, I stop the process. So, you can check with something like "if length(triggerBody()?['JBIOEmployee']?['Email']) > 0..." If it is false (i.e. there was no email), then I know not to bother with trying to remove them.
Good luck!
I must clarify the answer about checking the length of the email to see if there actually is one. That logic simply determines whether there IS an email, not whether it's legit (although usually it can't be one without the other!)
To actually determine whether the email is legitimate, you should use the action "Resolve Person." You supply the name of the list against which you want to validate it; the name of a Person column in that list; and the actual email of the user. If that email is an acceptable value for the list/column that you specified, the action will return legit user credentials. More importanly, if the user is not legit, it will return an error, which you can check for by using an action that will only run if that function returned an error. In this example, if the user isn't legit, I send an email to that effect and stop the workflow.
Of course, just because the user is legit does NOT mean that they are actually in a Permissions Group (which is significant if you are trying to remove them!) To handle THAT issue, you must use "error handling." I can establish whether the HTTP call was successful by adding an action immediately after it which sets a flag/variable to "TRUE", but I configure tht action so that it executes only if the HTTP call was successful. Next (and this is VERY important) I configure the action after THAT to run regardless of whether the action preceeding it (the one that sets the flag) was successful, failed, was skipped, or timed out, otherwise the whole workflow would end right there becuase of the error. This way, I have a flag/variable that is only TRUE if the HTTP call succeeded; otherwise, it's not TRUE.
FWIW, this is pretty much the basic way to handle errors: set some actions to run only if something was successful, and other actions to run only if it failed, timed out, or was skipped.
I hope that cleared things up.
-Boonie
THANK YOU VERY MUCH! I have now able to remove user from the SharePoint Group. 🙂
@mboonie - I have another question, hope you know it as well 🙂
Currently, I know how to remove the user in the SharePoint Group. However, I still manually getting the GroupID for each SharePoint Group, do you also have a process wherein i can extract all the SharePoint Group ID of a certain person?
Thank You! 🙂
Hi
I try to user this, but I get Bad Request?
{"odata.error":{"code":"-1, Microsoft.Data.OData.ODataException","message":{"lang":"en-US","value":"The parameter 'LoginName' in the request payload is not a valid parameter for the function import 'RemoveByLoginName'."}}}
clientRequestId: ff0b3b5d-23a4-45fd-9c06-57df465777fb
serviceRequestId: 86eb429f-50a6-2000-6c47-690b77b8b028
Try with a lowercase 'l', 'loginName' instead of 'LoginName'.
@jri Thank you for pointing that one out. It cost me an hour of my life.
These little inconsistencies are what makes working with these tools so cumbersome.
Adding a new user with "_api/web/SiteGroups/GetById(xxx)/Users" you need LoginName with a capital "L".
Removing a user with "_api/web/SiteGroups/GetById(xxx)/Users/RemoveByLoginName" you need loginName with a lower case letter "l".
No wonder I have grey hair.
Hi,
is struserid is the email of the users?
Has anyone got this error?
I looked at the group members and I do see test1 user on it, so I'm not sure why it keeps saying it doesn't exist or is not unique.
Episode Seven of Power Platform Connections sees David Warner and Hugo Bernier talk to Dian Taylor, alongside the latest news, product reviews, and community blogs. Use the hashtag #PowerPlatformConnects on social media for a chance to have your work featured on the show.
Super Users – 2023 Season 1 We are excited to kick off the Power Users Super User Program for 2023 - Season 1. The Power Platform Super Users have done an amazing job in keeping the Power Platform communities helpful, accurate and responsive. We would like to send these amazing folks a big THANK YOU for their efforts. Super User Season 1 | Contributions July 1, 2022 – December 31, 2022 Super User Season 2 | Contributions January 1, 2023 – June 30, 2023 Curious what a Super User is? Super Users are especially active community members who are eager to help others with their community questions. There are 2 Super User seasons in a year, and we monitor the community for new potential Super Users at the end of each season. Super Users are recognized in the community with both a rank name and icon next to their username, and a seasonal badge on their profile. Power Apps Power Automate Power Virtual Agents Power Pages Pstork1* Pstork1* Pstork1* OliverRodrigues BCBuizer Expiscornovus* Expiscornovus* ragavanrajan AhmedSalih grantjenkins renatoromao Mira_Ghaly* Mira_Ghaly* Sundeep_Malik* Sundeep_Malik* SudeepGhatakNZ* SudeepGhatakNZ* StretchFredrik* StretchFredrik* 365-Assist* 365-Assist* cha_cha ekarim2020 timl Hardesh15 iAm_ManCat annajhaveri SebS Rhiassuring LaurensM abm TheRobRush Ankesh_49 WiZey lbendlin Nogueira1306 Kaif_Siddique victorcp RobElliott dpoggemann srduval SBax CFernandes Roverandom schwibach Akser CraigStewart PowerRanger MichaelAnnis subsguts David_MA EricRegnier edgonzales zmansuri GeorgiosG ChrisPiasecki ryule AmDev fchopo phipps0218 tom_riha theapurva takolota Akash17 momlo BCLS776 Shuvam-rpa rampprakash ScottShearer Rusk ChristianAbata cchannon Koen5 a33ik Heartholme AaronKnox okeks Matren David_MA Alex_10 Jeff_Thorpe poweractivate Ramole DianaBirkelbach DavidZoon AJ_Z PriyankaGeethik BrianS StalinPonnusamy HamidBee CNT Anonymous_Hippo Anchov KeithAtherton alaabitar Tolu_Victor KRider sperry1625 IPC_ahaas zuurg rubin_boer cwebb365 Dorrinda G1124 Gabibalaban Manan-Malhotra jcfDaniel WarrenBelz Waegemma drrickryp GuidoPreite If an * is at the end of a user's name this means they are a Multi Super User, in more than one community. Please note this is not the final list, as we are pending a few acceptances. Once they are received the list will be updated.
Join us for an in-depth look into the latest updates across Microsoft Dynamics 365 and Microsoft Power Platform that are helping businesses overcome their biggest challenges today. Find out about new features, capabilities, and best practices for connecting data to deliver exceptional customer experiences, collaborating, and creating using AI-powered capabilities, driving productivity with automation—and building towards future growth with today’s leading technology. Microsoft leaders and experts will guide you through the full 2023 release wave 1 and how these advancements will help you: Expand visibility, reduce time, and enhance creativity in your departments and teams with unified, AI-powered capabilities.Empower your employees to focus on revenue-generating tasks while automating repetitive tasks.Connect people, data, and processes across your organization with modern collaboration tools.Innovate without limits using the latest in low-code development, including new GPT-powered capabilities. Click Here to Register Today!
We are excited to share the ‘Power Platform Communities Front Door’ experience with you! Front Door brings together content from all the Power Platform communities into a single place for our community members, customers and low-code, no-code enthusiasts to learn, share and engage with peers, advocates, community program managers and our product team members. There are a host of features and new capabilities now available on Power Platform Communities Front Door to make content more discoverable for all power product community users which includes ForumsUser GroupsEventsCommunity highlightsCommunity by numbersLinks to all communities Users can see top discussions from across all the Power Platform communities and easily navigate to the latest or trending posts for further interaction. Additionally, they can filter to individual products as well. Users can filter and browse the user group events from all power platform products with feature parity to existing community user group experience and added filtering capabilities. Users can now explore user groups on the Power Platform Front Door landing page with capability to view all products in Power Platform. Explore Power Platform Communities Front Door today. Visit Power Platform Community Front door to easily navigate to the different product communities, view a roll up of user groups, events and forums.
We are so excited to see you for the Microsoft Power Platform Conference in Las Vegas October 3-5 2023! But first, let's take a look back at some fun moments and the best community in tech from MPPC 2022 in Orlando, Florida. Featuring guest speakers such as Charles Lamanna, Heather Cook, Julie Strauss, Nirav Shah, Ryan Cunningham, Sangya Singh, Stephen Siciliano, Hugo Bernier and many more. Register today: https://www.powerplatformconf.com/