Is there a API to transfer ownership of folder(s) to another active users ?
Hi All,
We have a need where we need to transfer some shared folder to another active user. I looked at the API ref doc but could not find the rest call for this.
Can someone please point me to right doc if there is one regarding this ? If not what are the options available?
Thanks
MCBSR
-
Depending on the specific scenario it might require more than one API call. I'll walk through an example.
Let's say user A owns folder 1 currently, and you want to move folder 1 within user B's folder 2. However, user A doesn't have access to user B's folder 2. To do this, user A has to be added as collaborator to folder 2 before you can do the move. This is because user A has to have access to that folder to add content to it. If you don't add user A as collaborator beforehand, you get 403 error. Once user A has access to user B's folder 2, you can move the folder and change the owners.
Here are the API calls required for the scenario described above.
- You first want to add user B as a co-owner collaborator to folder 1 by using the Create Collaboration endpoint. You will make this call on behalf of user A with the As-User header.
- Second, you will add user A as a co-owner collaborator to user B's folder 2 by using the Create Collaboration endpoint. You will make this call on behalf of user B with the As-User header.
- Third, you will move the folder from user A's account to user B's account using the Update Folder Info endpoint. You will set the parent folder parameter to the id of folder 2. You will make this call on behalf of user A with the As-User header.
- Lastly, to remove User A's access to folder 2, you will delete the collaborations User A has on folders 1 and 2 using the Delete Collaboration endpoint.
-
Following this simply page: https://developer.box.com/guides/folders/single/change-owner/
I was able to transfer ownership from user A (current owner) to user B by simply:
- Get a user-client for user A
- Add a "collaboration" on the folder with user B as EDITOR
- Now update that collaboration to role "OWNER"
Done, it's that easy.
If you want, you can now delete the collaboration on the folder for user A, (which will now be listed as an Editor instead of the Owner.)I'm didn't have to do any "moving" at all, per the previous response, unless perhaps you were moving folders that were not in the roots of both users?
Please sign in to leave a comment.
Comments
4 comments