Giter Site home page Giter Site logo

Comments (1)

mooreds avatar mooreds commented on June 9, 2024

Hiya,

I agree that this isn't the clearest documentation. Sorry about that. The PHP client library doesn't support the two parameter based delete methods, but does support the request body based methods. These are documented here: https://fusionauth.io/docs/v1/tech/apis/groups/#request-body-4

If you know the user's membership id, you can delete it directly by building json like:

{
  "memberIds": [
    "222b884b-a0a1-4563-a957-89c7c0513e6e",
    "80d474bf-0dee-4009-b793-ec1255693fa3",
    "16d98a8b-4205-4441-8831-7e3f73154134"
  ]
}

If you don't know the membership ids (which I believe is what you are looking for) but do know the group and the user id, you can also remove memberships in that way:

{
  "members": {
    "1188edfc-cef3-4555-910e-181ddf6153c0": [
      
        "578e52df-83e8-48ca-899b-3aefd56e7fc5",
        "0928cf95-34d1-44cc-9114-da68a07e5ff8"
    ]
  }
}

Here's a curl example:

curl -XDELETE -H 'Content-type: application/json' -H "Authorization: $API_KEY" 'http://localhost:9011/api/group/member' -d '
{
  "members": {
    "63437023-6fc7-4f8f-9759-e325c896fef3": 
      [
        "00000000-0000-0000-0000-000000000006"
      ]
    
  }
}'

In PHP the object would look like this:

 $request_object = [
   "members" => [
         "63437023-6fc7-4f8f-9759-e325c896fef3" => [
            "00000000-0000-0000-0000-000000000006" 
         ] 
      ] 
]; 

Note that there is an issue with the docs linked above, they have an extra array between the group id and the list of user ids, but I'll get that fixed.

Hope this helps.

from fusionauth-php-client.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.