FusionAuth
    • Home
    • Categories
    • Recent
    • Popular
    • Pricing
    • Contact us
    • Docs
    • Login

    How to Fix 'could not find memberId' Errors When Removing Group Members in FusionAuth

    Scheduled Pinned Locked Moved Solved Q&A
    api
    2 Posts 1 Posters 2.7k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • W
      wesley
      last edited by

      I tried using delete_group_members() to remove users from a group, but each request failed with a “could not find memberId” error. I tried passing in both the group ID and user ID, but it didn’t work. I was only able to get it to work manually by passing a members_delete_request directly to the client. Is there a way to get delete_group_members() to work properly, or does it have a bug?

      W 1 Reply Last reply
      Reply Quote 0
      • W
        wesley @wesley
        last edited by

        You can work around this by passing the IDs directly in your request. Here’s an example of how to structure the request correctly:

        from fusionauth.fusionauth_client import FusionAuthClient
        
        api_key = 'your-fusionauth-api-key'
        base_url = 'https://your-fusionauth-instance.com'
        group_id = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
        user_ids_to_remove = [
            'yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy',
            'zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz'
        ]
        
        client = FusionAuthClient(api_key, base_url)
        member_delete_request = {'members': {group_id: user_ids_to_remove}}
        response = client.delete_group_members(member_delete_request)
        
        if response.was_successful():
            print("Successfully removed users from group!")
        else:
            print(f"Error: {response.error_response}")
        

        This approach correctly formats the request for the API to process and delete the specified users from the group.

        1 Reply Last reply
        Reply Quote 0
        • W wesley has marked this topic as solved on
        • danD dan moved this topic from Frequently Asked Questions (FAQ) on

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        • First post
          Last post