We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here.

Forum Discussion

sbrownnw's avatar
sbrownnw
Explorer | Level 4
2 years ago

restored folders and files have different ids than their originally added entities

given dropbox UI has no folders or files in it when I create a subfolder and add file1 to the subfolder and add file2 to the subfolder and note the ids for the new subfolder and two new files an...
  • Greg-DB's avatar
    2 years ago

    In the "restore file1" step, you're only restoring the file itself, not the original folder. When adding or restoring a file, if a parent path component (the folder, in this case) doesn't already exist, it will be automatically created. That automatically created folder is a new folder, not a restored folder (and it may or may not be at the same path as the original parent folder, e.g., since you can restore a file to a different location).

     

    As for the file ID of the restored file itself, I would expect that to be the same, and it is in my testing. Here's an example I just ran through:

    curl -X POST https://api.dropboxapi.com/2/files/create_folder_v2 \
      --header 'Authorization: Bearer <ACCESS_TOKEN>' \
      --header 'Content-Type: application/json' \
      --data '{"path":"/test_691719_folder"}'
    
    # {
    #   "metadata": {
    #     "name": "test_691719_folder",
    #     "path_lower": "/test_691719_folder",
    #     "path_display": "/test_691719_folder",
    #     "id": "id:25N5ksooX-sAAAAAAAQyqA"
    #   }
    # }  
    
    curl -X POST https://content.dropboxapi.com/2/files/upload \
      --header 'Authorization: Bearer <ACCESS_TOKEN>' \
      --header 'Content-Type: application/octet-stream' \
      --header 'Dropbox-API-Arg: {"path":"/test_691719_folder/test_691719_file"}' \
      --data-binary @'test.txt'
    
    # {
    #   "name": "test_691719_file",
    #   "path_lower": "/test_691719_folder/test_691719_file",
    #   "path_display": "/test_691719_folder/test_691719_file",
    #   "id": "id:25N5ksooX-sAAAAAAAQyqQ",
    #   "client_modified": "2023-06-14T18:42:28Z",
    #   "server_modified": "2023-06-14T18:42:29Z",
    #   "rev": "5fe1b50581a7c021eccc7",
    #   "size": 27,
    #   "is_downloadable": true,
    #   "content_hash": "cceac37da5288a6b6716737310c14305c9b16a6e0ff0abce4a306c3de3a59f75"
    # }
    
    curl -X POST https://api.dropboxapi.com/2/files/delete_v2 \
      --header 'Authorization: Bearer <ACCESS_TOKEN>' \
      --header 'Content-Type: application/json' \
      --data '{"path":"/test_691719_folder"}'
    
    # {
    #   "metadata": {
    #     ".tag": "folder",
    #     "name": "test_691719_folder",
    #     "path_lower": "/test_691719_folder",
    #     "path_display": "/test_691719_folder",
    #     "id": "id:25N5ksooX-sAAAAAAAQyqA"
    #   }
    # }
    
    curl -X POST https://api.dropboxapi.com/2/files/restore \
      --header 'Authorization: Bearer <ACCESS_TOKEN>' \
      --header 'Content-Type: application/json' \
      --data '{"path":"/test_691719_folder/test_691719_file","rev":"5fe1b50581a7c021eccc7"}'
    
    # {
    #   "name": "test_691719_file",
    #   "path_lower": "/test_691719_folder/test_691719_file",
    #   "path_display": "/test_691719_folder/test_691719_file",
    #   "id": "id:25N5ksooX-sAAAAAAAQyqQ",
    #   "client_modified": "2023-06-14T18:42:28Z",
    #   "server_modified": "2023-06-14T18:43:47Z",
    #   "rev": "5fe1b5501cafb021eccc7",
    #   "size": 27,
    #   "is_downloadable": true,
    #   "content_hash": "cceac37da5288a6b6716737310c14305c9b16a6e0ff0abce4a306c3de3a59f75"
    # }  
    
    curl -X POST https://api.dropboxapi.com/2/files/get_metadata \
      --header 'Authorization: Bearer <ACCESS_TOKEN>' \
      --header 'Content-Type: application/json' \
      --data '{"path":"/test_691719_folder"}'
    
    # {
    #   ".tag": "folder",
    #   "name": "test_691719_folder",
    #   "path_lower": "/test_691719_folder",
    #   "path_display": "/test_691719_folder",
    #   "id": "id:25N5ksooX-sAAAAAAAQyrA"
    # }
    
    curl -X POST https://api.dropboxapi.com/2/files/get_metadata \
      --header 'Authorization: Bearer <ACCESS_TOKEN>' \
      --header 'Content-Type: application/json' \
      --data '{"path":"/test_691719_folder/test_691719_file"}'  
    
    # {
    #   ".tag": "file",
    #   "name": "test_691719_file",
    #   "path_lower": "/test_691719_folder/test_691719_file",
    #   "path_display": "/test_691719_folder/test_691719_file",
    #   "id": "id:25N5ksooX-sAAAAAAAQyqQ",
    #   "client_modified": "2023-06-14T18:42:28Z",
    #   "server_modified": "2023-06-14T18:43:47Z",
    #   "rev": "5fe1b5501cafb021eccc7",
    #   "size": 27,
    #   "is_downloadable": true,
    #   "content_hash": "cceac37da5288a6b6716737310c14305c9b16a6e0ff0abce4a306c3de3a59f75"
    # }

    If something's not working properly for you though, please share the steps/code to reproduce the issue and show us the unexpected output or error so we can look into it.