How to get Owner's collaboration ID through Box API
AnsweredI want to transfer folders from one User to another user using Collaboration Transfer Method following these posts.
https://developer.box.com/guides/users/deprovision/transfer-folders/#fetch-collaboration-id-as-transfer-to-user
But now blocked by this step "Remove Transfer From User as Owner",
because It does not work to get Owner collaboration ID through "get collaboration endpoint" and the return result only include Co-Owner collaboration ID.
Is there any other way to get Owner collaboration ID?
-
To transfer folders from one user to another using the Collaboration Transfer Method in Box, and to address the issue of not being able to get the Owner collaboration ID through the “get collaboration endpoint,” you can try the following steps:
Use the Transfer Owned Folders API:
Instead of relying on the collaboration ID, you can use the transferOwnedFolder endpoint, which is designed to move all content from one user directly to another. This method does not require fetching the collaboration ID.
Here’s an example of AarpMembership how to use this endpoint:
Pythonimport boxsdk
client = boxsdk.Client('YOUR_ACCESS_TOKEN')
source_user_id = 'SOURCE_USER_ID'
destination_user_id = 'DESTINATION_USER_ID'source_user = client.user(source_user_id)
destination_user = client.user(destination_user_id)folder = source_user.transfer_content(destination_user)
print(f'Transferred folder to user {destination_user.id}')
AI-generated code. Review and use carefully. More info on FAQ.
Promote Co-Owner to Owner:
If you need to change the ownership of a specific folder, you can promote the Co-Owner to Owner. This involves:
Adding the new owner as a Co-Owner.
Promoting the Co-Owner to Owner.
Re-fetching the collaboration list to locate the previous owner -
Hi Jennie,
As you suggested, I can get the original Owner user 's collaboration ID after promoting another user to Owner. But it seems that the user collaboration ID does not work after I recover the original Owner user to Owner.
I use this Box SDK java code and it will throw " not_found - Not Found " Error.
BoxCollaboration co = new BoxCollaboration(api,"XXXXXXXX");I wonder if that is because the collaboration ID will be set to NULL when the user role is Owner. Or there is any other way to get the Owner's collaboration ID directly?
Thanks.
Please sign in to leave a comment.
Comments
3 comments