cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
What’s new: end-to-end encryption, Replay and Dash updates. Find out more about these updates, new features and more here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Move file from users home folder to admin home folder

Move file from users home folder to admin home folder

sarshavs
Explorer | Level 3

Hello im using team space configuration and trying to use this EP - 

https://api.dropboxapi.com/2/files/move_v2

to move file from user's home folder to  admin home folder and i get 409, tried to add admin header but its not working...

Do you have support to such case? if so please share the EP (preferably v2) and relevant params.

Thanks alot!

9 Replies 9

Здравко
Legendary | Level 20

Hi @sarshavs,

If you take a look on the response body, there should be more descriptive message of what's got wrong.

Happy new year.

sarshavs
Explorer | Level 3

Thanks, i get {'.tag': 'path', 'path': {'.tag': 'not_found'}
i tried using the user's path and also the file id both get similar error - not found/look up error

 

sarshavs
Explorer | Level 3

to be more specific im trying to move file from - {user name}/file1.txt -> {admin name}/file1.txt

using admin client .

Здравко
Legendary | Level 20

You have set either incorrect path or wrong namespace (or both of them). Try list all files/folders in your root (empty path) to see where are you and navigate to the correct path. 😉

Good luck.

sarshavs
Explorer | Level 3

Again, i need to move file between different namespaces so john root namespace is X and admin namespace is Y. How could i move file from X namespace to Y namespace? 
The problem is the root namespace is different for each user and the admin, and the root namespace for admin list only admin's folder and all the team folder but without all other user's home folder.

Здравко
Legendary | Level 20

No, all namespaces (user/member folders, including the one of the admin) are in the same account root of a single account. It sounds like you have different accounts (that by mistake you count as a same). In such a case you can copy desired content in other ways. One possible such a way is to share (possibly temporary) the desired file (or containing folder) between the accounts and do whatever needed (including eventually moving as you're trying). Another possibility is to copy by reference (or by link - shared or temporary). Choose whatever best matches your use case.

 

PS: Are you sure the account root namespace has been set correctly and not only independent member/admin namespace only? 🤔 If not make it sure! As I said, just list all files/folders with empty path. Is the result showing some member admin folder or the account' root? 🙂 Don't be sure for something you're not, better try/check.

Greg-DB
Dropbox Staff

@sarshavs The /2/files/move_v2 endpoint only supports the Dropbox-API-Select-Admin "Team Admin" mode, meaning it can "can access content of team folders and team spaces but not the team members' home namespaces".

 

That means you can't use /2/files/move_v2 to administratively move a file from the user's home folder. That being the case, using the copy reference feature that Здравко mentioned may be a good solution; you could use that to copy the file from one account to the other (and then delete the original if needed).

sarshavs
Explorer | Level 3

Maybe im missing something here..
Im using team admin account to move file from user's home folder to admin's account home folder. when im using get_current_account to get the root id i get different ids for admin and for the user.

 

for example sarshavs user have root id : 4572232609 and Tomer - team admin have root id - 4572219937 now what should i do to move file from sarshavs home folder to Tomer home folder?
Thanks  

Здравко
Legendary | Level 20

As I said already and if you haven't count home name namespace as root namespace, then sarshavs and Tomer participate in different teams. Anyways...

In all cases (as Greg agreed too) you can use copy by reference and remove the file from the source at the end. If we assume you can access sarshavs files with user id $sarshavsUID and access token $sarshavsToken, then following call would give you a file reference:

fref=`curl -X POST https://api.dropboxapi.com/2/files/copy_reference/get -H "Authorization: Bearer $sarshavsToken" -H "Dropbox-Api-Select-User: $sarshavsUID" -H 'Content-Type: application/json' -d '{"path":"/Path/To/Existing/file.ext"}' | jq -r .copy_reference`

 Now $fref holds the received reference. Next if we assume $tomerUID is id of Tomer and $tomerToken is corresponding token, following would paste the copied before file in Tomer owned space:

curl -X POST https://api.dropboxapi.com/2/files/copy_reference/save -H "Authorization: Bearer $tomerToken" -H "Dropbox-Api-Select-User: $tomerUID" -H 'Content-Type: application/json' -d "{\"copy_reference\":\"$fref\",\"path\":\"/Path/To/Paste/file.ext\"}"

 The above are HTTP shell calls. Of course, you can use whatever you're using till now following the same pattern. In such a way you're not limited to any folder or account. 😉

Hope this helps.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Здравко Legendary | Level 20
  • User avatar
    sarshavs Explorer | Level 3
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?