cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
golfnutt82
Impactful Individual
Impactful Individual

Remove User from SharePoint document library folder User Group

Good morning,
I am at my wits end trying to figure this out.
I have tried just about every solution I found on this site and others and I still can figure out how to remove a user from a SharePoint user group. What am I missing?
Thank you!


Here is what I have now:

golfnutt82_0-1636377630177.png

Here's what is being returned:

golfnutt82_3-1636377852910.png

golfnutt82_2-1636377760727.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
eliotcole
Super User
Super User

Yeah, that LoginName is not the same as Name, @golfnutt82, that's for certain.

 

If you could also do some StartPage fu (never Google 😉) to see if you can find the LoginName format that'd be awesome.

 

EDIT - OK, I just did an _api/site/Owner call which showed me my LoginName, and it's in this format, so you need to extract whatever looks like this from your previous step:

 

 

c:0o.c|federateddirectoryclaimprovider|aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee_o

 

 

EDIT 2 - So probably grabbing d.LoginName would work for you if you're already getting userData somewhere else, like an _api/Web/GetUserById(6) request (with the appropriate Id, of course) ...

 

Which reminds me ... I can't remember if I mentioned it already, but perhaps if you already have that Id, you could try the following (obviously not with a 6 in there):

 

_api/web/sitegroups/GetById(3747)/Users/RemoveById(6)

 

Having a brief look around that appears to work for others, and you don't have to worry about format.

 

EDIT 3 - Oh, also, @golfnutt82, if you wanna make the data you get a bit more honed in, then you can use the ODATA filters like a boss to perform filter and select actions to really needle the data you get from calls:

https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/use-odata-query-operations-in-sharepoint-...

View solution in original post

16 REPLIES 16
eliotcole
Super User
Super User

Hiya, @golfnutt82 , good to see you again. 👋

 

Could you show (however obfuscated) the whole flow, so there's some more context, please?

 

Also, could you please send the whole error message from that status 400 message?

 

Oh, and one question: Is the SharePoint group that you're referring to a native SP group, or a 365 group?

 

---

 

Separately, my initial instinct from what I can see (ODATA error) is that you're missing some additional information on the end of your SharePoint HTTP request, or perhaps just slightly mis-configured in the JSON. However ODATA stuff is usually handled in the URI.

 

EDIT - This document (not directly relateable, perhaps) seems to support that.

 

Try adding a bracketed (loginName) after the last word in the URI like so ... obviously placing the actual login name there 😉:

_api/web/sitegroups/GetById(3747)/Users/RemoveByLoginName(loginName)

 

golfnutt82
Impactful Individual
Impactful Individual

Hello again,
Here is more of the workflow.
Yes these are standard SP groups

golfnutt82_3-1636378954435.png

golfnutt82_4-1636379025413.png

 

 


The 400 message continued is.

golfnutt82_0-1636378502682.png

golfnutt82_1-1636378535095.png

golfnutt82_2-1636378576128.png

 

 

eliotcole
Super User
Super User

Nice one, thanks.

 

Would definitely be cool to see more of that "message" header, though. The one that begins: "{\"odata.error\":{\"code\":\"-1..."

 

If that pure flailing attempt at a fix (putting the ODATA information in the URI) seems to be something that could work out, @golfnutt82 ... then I'm also thinking that if you're extracting the user's ID, then you may just wish to use removeById(), instead. Same thing, put it in the URI there.

golfnutt82
Impactful Individual
Impactful Individual

I actually tried this and the workflow ran but didnt remove the user from the group.

golfnutt82_0-1636382327468.png

 



eliotcole
Super User
Super User

OK, but (on the incident that you have reported) have you tried adding a bracket to the end of the RemoveByLoginName string with the Login Name?

 

_api/web/sitegroups/GetById(3747)/Users/RemoveByLoginName(loginName)

 

Hi, yep did that and still have an error.

golfnutt82_0-1636385143269.png

 

eliotcole
Super User
Super User

OK, @golfnutt82, can you please show me your HTTP request for this specific action, from the edit screen, as it looks right now?

golfnutt82_0-1636385675762.png

 

I gave you the wrong error output. 
Here is the correct one.

golfnutt82_1-1636385902146.png

 

eliotcole
Super User
Super User

OK, that's odd, have you tried googling any of these errors?

 

If I was just reading this blank, this error would suggest that the last time it was run it still had the Body that you specified in your opening post.


@golfnutt82 wrote:

"The parameter 'LoginName' in the request payload is not a valid parameter for the function import 'RemoveByLoginName'."


Otherwise it is data that is coming out of nowhere, to be honest ... and I'm baffled by it.

eliotcole
Super User
Super User

OK, that's a bit more progressive, @golfnutt82 🙂 ... what we know now is that you're submitting properly, but just need to format it properly.

 

I suspect the login name doesn't have text with a comma after it. Most likely it's an email address, or the part that comes before the email address.

 

I believe I used it the other week, lemme just check.

 

In the meantime, take a look around for the LoginName format. 👍

Here is the user group associated with the library.

 

golfnutt82_2-1636386522476.png

 

golfnutt82_1-1636386460323.png


Here is the library:

golfnutt82_3-1636386625793.png

Yes, I am baffled as well.
Ive tried everything

 

eliotcole
Super User
Super User

Yeah, that LoginName is not the same as Name, @golfnutt82, that's for certain.

 

If you could also do some StartPage fu (never Google 😉) to see if you can find the LoginName format that'd be awesome.

 

EDIT - OK, I just did an _api/site/Owner call which showed me my LoginName, and it's in this format, so you need to extract whatever looks like this from your previous step:

 

 

c:0o.c|federateddirectoryclaimprovider|aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee_o

 

 

EDIT 2 - So probably grabbing d.LoginName would work for you if you're already getting userData somewhere else, like an _api/Web/GetUserById(6) request (with the appropriate Id, of course) ...

 

Which reminds me ... I can't remember if I mentioned it already, but perhaps if you already have that Id, you could try the following (obviously not with a 6 in there):

 

_api/web/sitegroups/GetById(3747)/Users/RemoveById(6)

 

Having a brief look around that appears to work for others, and you don't have to worry about format.

 

EDIT 3 - Oh, also, @golfnutt82, if you wanna make the data you get a bit more honed in, then you can use the ODATA filters like a boss to perform filter and select actions to really needle the data you get from calls:

https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/use-odata-query-operations-in-sharepoint-...

Hello Eliot,
Sorry I fell off the map for awhile due to having to work on other things.
I did use the following without success:

golfnutt82_0-1636475923343.png

golfnutt82_3-1636476245551.png

 

I will try your edit two suggestion now.

 

YES! Your EDIT 2 suggestion worked!!!
Thank  you!

golfnutt82_1-1636476809768.png

 

 

eliotcole
Super User
Super User

Niiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiice, @golfnutt82 🏆🏆🏆🏆

 

Oh! ... and it turns out that I had mentioned it a bit earlier ... but what matters is that you're now able to remove those users. 👍

Helpful resources

Announcements

Celebrating the May Super User of the Month: Laurens Martens

  @LaurensM  is an exceptional contributor to the Power Platform Community. Super Users like Laurens inspire others through their example, encouragement, and active participation. We are excited to celebrated Laurens as our Super User of the Month for May 2024.   Consistent Engagement:  He consistently engages with the community by answering forum questions, sharing insights, and providing solutions. Laurens dedication helps other users find answers and overcome challenges.   Community Expertise: As a Super User, Laurens plays a crucial role in maintaining a knowledge sharing environment. Always ensuring a positive experience for everyone.   Leadership: He shares valuable insights on community growth, engagement, and future trends. Their contributions help shape the Power Platform Community.   Congratulations, Laurens Martens, for your outstanding work! Keep inspiring others and making a difference in the community!   Keep up the fantastic work!        

Check out the Copilot Studio Cookbook today!

We are excited to announce our new Copilot Cookbook Gallery in the Copilot Studio Community. We can't wait for you to share your expertise and your experience!    Join us for an amazing opportunity where you'll be one of the first to contribute to the Copilot Cookbook—your ultimate guide to mastering Microsoft Copilot. Whether you're seeking inspiration or grappling with a challenge while crafting apps, you probably already know that Copilot Cookbook is your reliable assistant, offering a wealth of tips and tricks at your fingertips--and we want you to add your expertise. What can you "cook" up?   Click this link to get started: https://aka.ms/CS_Copilot_Cookbook_Gallery   Don't miss out on this exclusive opportunity to be one of the first in the Community to share your app creation journey with Copilot. We'll be announcing a Cookbook Challenge very soon and want to make sure you one of the first "cooks" in the kitchen.   Don't miss your moment--start submitting in the Copilot Cookbook Gallery today!     Thank you,  Engagement Team

Announcing Power Apps Copilot Cookbook Gallery

We are excited to share that the all-new Copilot Cookbook Gallery for Power Apps is now available in the Power Apps Community, full of tips and tricks on how to best use Microsoft Copilot as you develop and create in Power Apps. The new Copilot Cookbook is your go-to resource when you need inspiration--or when you're stuck--and aren't sure how to best partner with Copilot while creating apps.   Whether you're looking for the best prompts or just want to know about responsible AI use, visit Copilot Cookbook for regular updates you can rely on--while also serving up some of your greatest tips and tricks for the Community. Check Out the new Copilot Cookbook for Power Apps today: Copilot Cookbook - Power Platform Community.  We can't wait to see what you "cook" up!    

Welcome to the Power Automate Community

You are now a part of a fast-growing vibrant group of peers and industry experts who are here to network, share knowledge, and even have a little fun.   Now that you are a member, you can enjoy the following resources:   Welcome to the Community   News & Announcements: The is your place to get all the latest news around community events and announcements. This is where we share with the community what is going on and how to participate.  Be sure to subscribe to this board and not miss an announcement.   Get Help with Power Automate Forums: If you're looking for support with any part of Power Automate, our forums are the place to go. From General Power Automate forums to Using Connectors, Building Flows and Using Flows.  You will find thousands of technical professionals, and Super Users with years of experience who are ready and eager to answer your questions. You now have the ability to post, reply and give "kudos" on the Power Automate community forums. Make sure you conduct a quick search before creating a new post because your question may have already been asked and answered. Galleries: The galleries are full of content and can assist you with information on creating a flow in our Webinars and Video Gallery, and the ability to share the flows you have created in the Power Automate Cookbook.  Stay connected with the Community Connections & How-To Videos from the Microsoft Community Team. Check out the awesome content being shared there today.   Power Automate Community Blog: Over the years, more than 700 Power Automate Community Blog articles have been written and published by our thriving community. Our community members have learned some excellent tips and have keen insights on the future of process automation. In the Power Automate Community Blog, you can read the latest Power Automate-related posts from our community blog authors around the world. Let us know if you'd like to become an author and contribute your own writing — everything Power Automate-related is welcome.   Community Support: Check out and learn more about Using the Community for tips & tricks. Let us know in the Community Feedback  board if you have any questions or comments about your community experience. Again, we are so excited to welcome you to the Microsoft Power Automate community family. Whether you are brand new to the world of process automation or you are a seasoned Power Automate veteran - our goal is to shape the community to be your 'go to' for support, networking, education, inspiration and encouragement as we enjoy this adventure together.     Power Automate Community Team

Hear what's next for the Power Up Program

Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram, including a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the link below to sign up today! https://aka.ms/PowerUp  

Tuesday Tip | How to Report Spam in Our Community

It's time for another TUESDAY TIPS, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.   As our community family expands each week, we revisit our essential tools, tips, and tricks to ensure you’re well-versed in the community’s pulse. Keep an eye on the News & Announcements for your weekly Tuesday Tips—you never know what you may learn!   Today's Tip: How to Report Spam in Our Community We strive to maintain a professional and helpful community, and part of that effort involves keeping our platform free of spam. If you encounter a post that you believe is spam, please follow these steps to report it: Locate the Post: Find the post in question within the community.Kebab Menu: Click on the "Kebab" menu | 3 Dots, on the top right of the post.Report Inappropriate Content: Select "Report Inappropriate Content" from the menu.Submit Report: Fill out any necessary details on the form and submit your report.   Our community team will review the report and take appropriate action to ensure our community remains a valuable resource for everyone.   Thank you for helping us keep the community clean and useful!

Users online (4,184)