Delete User API

We need to remove more than 200 users in our instance and we want to do this in bulk. For that we thought on calling the User API via scripting so it could execute quickly.

However, the API is returning an error 400 referring that the user owns datasets and therefore can't be deleted. We already have confirmed that the user does not own anything in our instance so is there a problem with this request?

Thank you

Tagged:

Answers

  • GrantSmith
    GrantSmith Coach
    edited September 2021

    Do they own anything else besides a dataset like a view, fusion or dataflow?

    Have you tried utilizing the CLI tool and the swap-owner command to try and swap anything they might have over to a new user?

    https://domohelp.domo.com/hc/en-us/articles/360043437733-Command-Line-Interface-CLI-Tool

    **Was this post helpful? Click Agree or Like below**
    **Did this solve your problem? Accept it as a solution!**
  • @GrantSmith we have just tried the swap-owner command in JavaCLI and it moved everything for the new user (which was nothing because the user we want to delete does not have anything) and we still can't delete it.

    Maybe the API suffered some changes, we followed the documentation here: https://developer.domo.com/docs/users-api-reference/users-2#Delete%20a%20user

  • this question was the inspiration for a tutorial:



    to just get datasets owned by a specific user, just hit that query API with the body

    {"entities":["DATASET"],"filters":[{"filterType":"term","field":"owned_by_id","value":"1527841788:USER","name":"George Read","not":false}],"combineResults":true,"query":"*","count":30,"offset":0,"sort":{"isRelevance":false,"fieldSorts":[{"field":"create_date","sortOrder":"DESC"}]}}
    


    then to alter permissions. hit the Permissions API. set the owner to 'can share' or 'no access'. then set a new owner to the dataaset

    {
        "type": "USER",
        "id": "1893952720",
        "accessLevel": "OWNER"
    }
    
    Jae Wilson
    Check out my 🎥 Domo Training YouTube Channel 👨‍💻

    **Say "Thanks" by clicking the ❤️ in the post that helped you.
    **Please mark the post that solves your problem by clicking on "Accept as Solution"