We have a number of users outside of our domain that were inappropriately added as managed users. I want to roll them off the enterprise and convert them to external users, but when using box-sdk-gen and emit a client.users.update_user_by_id(xxxx, enterprise=None) nothing happens. It seems to execute successfully, but fetching that user again shows that the enterprise information is still present.
If I try to execute with enterprise={'id':None} or enterprise='null' I get a 403 insufficient permissions error. I noticed that the type on the enterprise field is str so that’s why I tried the latter.
What am I doing wrong? Can anyone point me to how I roll these users off the enterprise?
Thanks
Best answer by djones4
I did a quick, non-exhaustive, check on other endpoints and there are many fields across multiple endpoints which the api accepts null but would fall victim to the same bug. I am moving to the github issue for further discussion on this, hopefully engaging with the maintainers to find a solution.
I believe I solved this, it’s a bug in the library. When serializing the request body, it filters out values that are None, and values like “null” are not acceptable for this. I believe I was getting 403 because the server checking for my ability to change the enterprise to “null” was not found, and it assumed I was trying to change a user to an enterprise I wasn’t authorized to change to.
I modified the source code of the library, changing the method update_user_by_id within the file .venv\Lib\site-packages\box_sdk_gen\managers\users.py to include this at line 618:
I did a quick, non-exhaustive, check on other endpoints and there are many fields across multiple endpoints which the api accepts null but would fall victim to the same bug. I am moving to the github issue for further discussion on this, hopefully engaging with the maintainers to find a solution.