Transfer owned folders

SOLVED
Go to solution
Highlighted
New Contributor

Transfer owned folders

I am attempting to use the API to transfer owned folders to another account so that I can delete the original account.

 

Here is the API call that I'm making:

 

https://api.box.com/2.0/users/123456/folders/0 -H 'Authorization: Bearer redactedbearertoken' -H 'Content-Type: application/json' -d '{"owned_by": {"id": "987654"}}' -X PUT

 

123456 is the user's account, 987654 is the account transfer destination.

 

When I run this code I get a 400 error (bad_request) with the message "Cannot transfer to folder".

 

The OAUTH account that's running the script has the following administrative privileges:

  • Manage users
  • View users' content
  • Edit users' content
  • Log in to users' accounts

Not sure what to do. My script worked just fine (deleting accounts) until we had the Governance module installed, now it seems that I have to transfer ownership of all the files to another user before I can delete it.

 

3 REPLIES 3
Highlighted
Box Employee

Re: Transfer owned folders

Hi @szinski, I am not too sure what's going on here but I'm investigating. I just want to check that the access token represents a user with admin privileges, and that the target user ID is a user in your enterprise?


---
Developer Advocate @ Box
Highlighted
New Contributor

Re: Transfer owned folders

Got it working. Posting the solution to help others.

 

I had to enable the 'Read and write all files and folders stored in Box' and 'Manage Users' scopes, then grab a new token pair and retried my script, all is working now.

 

Highlighted
Box Employee

Re: Transfer owned folders

@szinski thank you so much. I've pushed an update to our reference docs to explicitly call out that you need the `Read and write all files and folders stored in Box` scope to transfer files


---
Developer Advocate @ Box