You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.

Forum Discussion

mittinga's avatar
mittinga
Explorer | Level 4
3 months ago

Rename a file via API from shared link

Hello everyone,

 

I’m currently working with the Dropbox API, and I’m trying to rename a file within a shared folder. The folder is shared with me via a shared link, and I have the necessary edit permissions on the file. However, I’m encountering a problem where I can’t seem to get the full path to use in the files/move_v2 API endpoint to rename the file.

 

Here’s a quick summary of what I’ve done:

 

•I have a shared link to the file/folder.

•I’m able to access the file using the shared link and even fetch file metadata.

•I want to rename the file and keep it in the same folder using the Dropbox API.

 

The Problem:

 

The Dropbox API’s files/move_v2 requires the full path of the file, but when using a shared link, I’m not getting the full path back. I only have the file’s metadata like the file ID, and I can’t seem to directly rename it without knowing the full path.

 

Questions:

 

1. Is there a way to retrieve the full path of a file via a shared link, so I can rename it?

2.Can I rename the file using just the file ID instead of the full path in the files/move_v2 API?

3.Is there a different approach I should be taking when working with shared links and renaming files?

 

Any help or advice on how to rename a file when the full path isn’t directly available would be greatly appreciated!

  • mittinga The path_lower field will not always be returned; please refer to the documentation for information on when any particular field will be returned. (Be sure to click on FileLinkMetadata and/or FolderLinkMetadata under the "Returns" section to expand the information for those types.)

     

    Note also though that if you are connected to the correct account, for the item to be found in the account and the path to be returned, the call will need to be using a relevant root containing the item. So for instance, if the item is in the team space, you'll need to set the "Dropbox-API-Path-Root" header to set the root to the team space. Refer to the Team Files Guide for information on how to do so.

  • Здравко's avatar
    Здравко
    Legendary | Level 20

    mittinga wrote:

    ... The folder is shared with me via a shared link, and I have the necessary edit permissions on the file. However, I’m encountering a problem where I can’t seem to get the full path to use in the files/move_v2 API endpoint to rename the file.

    ...


    Hi mittinga,

    What do you mean "necessary edit permissions"? Does this suppose mounted folder or not? 🧐

    You may get path, etc. for mounted entries only (files or folder). "files/move_v2" doesn't work on links directly!

    Good luck.

    • mittinga's avatar
      mittinga
      Explorer | Level 4

      Hi,
      thank you for the reply.
      when I call "get_shared_link_metadata" I am not getting path. only name. can't rename with name. 
      maybe this will help:

      "visibility_policies": [
      {
      "policy": {
      ".tag": "public"
      },
      "resolved_policy": {
      ".tag": "shared_folder_only"
      },
      "allowed": false,
      "disallowed_reason": {
      ".tag": "restricted_by_shared_folder"
      }
      },

       

      • Greg-DB's avatar
        Greg-DB
        Icon for Dropbox Staff rankDropbox Staff

        mittinga The path_lower field will not always be returned; please refer to the documentation for information on when any particular field will be returned. (Be sure to click on FileLinkMetadata and/or FolderLinkMetadata under the "Returns" section to expand the information for those types.)

         

        Note also though that if you are connected to the correct account, for the item to be found in the account and the path to be returned, the call will need to be using a relevant root containing the item. So for instance, if the item is in the team space, you'll need to set the "Dropbox-API-Path-Root" header to set the root to the team space. Refer to the Team Files Guide for information on how to do so.