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
    Frequently Asked Questions (FAQ)
    api
    1
    2
    15
    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
        • First post
          Last post