We’re Still Here to Help (Even Over the Holidays!) - find out more here.
Forum Discussion
harshap
7 years agoHelpful | Level 6
How to detect Dropbox folder is renamed. via Dropbox http-api or java-sdk
After rename folder in Dropbox. Dropbox 2/files/list_folder/continue api give response that indicate old folder and it's all sub-folder deleted and folder with new name and all old sub-folder ...
- 7 years ago
[Cross-linking for reference: https://stackoverflow.com/questions/54417566/how-to-detect-dropbox-folder-is-renamed-via-dropbox-http-api-or-java-sdk ]
If a file or folder is renamed, the new entry will have the same 'id' as the previous (non-deleted) entry.
So, if you want to keep track of renames, you should keep the existing state, from the previous /2/files/list_folder and /2/files/list_folder/continue calls.
Here's a more complete example:
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/test_325818\"}" | jqp # { # "metadata": { # "name": "test_325818", # "path_lower": "/test/test_325818", # "path_display": "/Test/test_325818", # "id": "id:25N5ksooX-sAAAAAAAM5zg" # } # } curl -X POST https://content.dropboxapi.com/2/files/upload \ --header "Authorization: Bearer <ACCESS_TOKEN>" \ --header "Dropbox-API-Arg: {\"path\": \"/test/test_325818/test_325818.txt\"}" \ --header "Content-Type: application/octet-stream" \ --data-binary "test data" | jqp # { # "name": "test_325818.txt", # "path_lower": "/test/test_325818/test_325818.txt", # "path_display": "/test/test_325818/test_325818.txt", # "id": "id:25N5ksooX-sAAAAAAAM50A", # "client_modified": "2019-01-29T19:08:37Z", # "server_modified": "2019-01-29T19:08:37Z", # "rev": "73c60021eccc7", # "size": 9, # "content_hash": "824979ede959fefe53082bc14502f8bf041d53997ffb65cbbe3ade5803f7fb76" # } curl -X POST https://api.dropboxapi.com/2/files/list_folder \ --header "Authorization: Bearer <ACCESS_TOKEN>" \ --header "Content-Type: application/json" \ --data "{\"path\": \"/test\",\"recursive\": true}" | jqp # { # "entries": [ # { # ".tag": "folder", # "name": "test", # "path_lower": "/test", # "path_display": "/test", # "id": "id:25N5ksooX-sAAAAAAAM5zw" # }, # { # ".tag": "folder", # "name": "test_325818", # "path_lower": "/test/test_325818", # "path_display": "/Test/test_325818", # "id": "id:25N5ksooX-sAAAAAAAM5zg" # }, # { # ".tag": "file", # "name": "test_325818.txt", # "path_lower": "/test/test_325818/test_325818.txt", # "path_display": "/test/test_325818/test_325818.txt", # "id": "id:25N5ksooX-sAAAAAAAM50A", # "client_modified": "2019-01-29T19:08:37Z", # "server_modified": "2019-01-29T19:08:37Z", # "rev": "73c60021eccc7", # "size": 9, # "content_hash": "824979ede959fefe53082bc14502f8bf041d53997ffb65cbbe3ade5803f7fb76" # } # ], # "cursor": "AAEZHC5JNB-5N9UR8wHEdcHTUEbi-u78UPPhZfrt9hPLMhmbDIgPn6pFEmlMk7fItVUgMRA4dpMhLtwuqjlhTYgcDraWbCIpZ0rKJsPui2yTPXNIWIoCCjWzHm_osUCUWMOwGPLDqcXNMvhx5dUAz6fU7QaK0pGJAF08QdpQFV_KJC73PT1MT_DX1TYuDPBWkP4", # "has_more": false # } curl -X POST https://api.dropboxapi.com/2/files/move_v2 \ --header "Authorization: Bearer <ACCESS_TOKEN>" \ --header "Content-Type: application/json" \ --data "{\"from_path\": \"/test/test_325818\",\"to_path\": \"/test/test_325818_renamed\"}" | jqp # { # "metadata": { # ".tag": "folder", # "name": "test_325818_renamed", # "path_lower": "/test/test_325818_renamed", # "path_display": "/Test/test_325818_renamed", # "id": "id:25N5ksooX-sAAAAAAAM5zg" # } # } curl -X POST https://api.dropboxapi.com/2/files/list_folder/continue \ --header "Authorization: Bearer <ACCESS_TOKEN>" \ --header "Content-Type: application/json" \ --data "{\"cursor\": \"AAEZHC5JNB-5N9UR8wHEdcHTUEbi-u78UPPhZfrt9hPLMhmbDIgPn6pFEmlMk7fItVUgMRA4dpMhLtwuqjlhTYgcDraWbCIpZ0rKJsPui2yTPXNIWIoCCjWzHm_osUCUWMOwGPLDqcXNMvhx5dUAz6fU7QaK0pGJAF08QdpQFV_KJC73PT1MT_DX1TYuDPBWkP4\"}" | jqp # { # "entries": [ # { # ".tag": "deleted", # "name": "test_325818.txt", # "path_lower": "/test/test_325818/test_325818.txt", # "path_display": "/test/test_325818/test_325818.txt" # }, # { # ".tag": "deleted", # "name": "test_325818", # "path_lower": "/test/test_325818", # "path_display": "/Test/test_325818" # }, # { # ".tag": "folder", # "name": "test_325818_renamed", # "path_lower": "/test/test_325818_renamed", # "path_display": "/Test/test_325818_renamed", # "id": "id:25N5ksooX-sAAAAAAAM5zg" # }, # { # ".tag": "file", # "name": "test_325818.txt", # "path_lower": "/test/test_325818_renamed/test_325818.txt", # "path_display": "/test/test_325818_renamed/test_325818.txt", # "id": "id:25N5ksooX-sAAAAAAAM50A", # "client_modified": "2019-01-29T19:08:37Z", # "server_modified": "2019-01-29T19:09:03Z", # "rev": "73c64021eccc7", # "size": 9, # "content_hash": "824979ede959fefe53082bc14502f8bf041d53997ffb65cbbe3ade5803f7fb76" # } # ], # "cursor": "AAHt9Zlq5FimhWx0HZfGESi174eBTbSFXHS0ZyMQq5PcBgpWjIah3fS6iRKkyqHbmWr5MG-7cX4Bq8p6f6BF0nZ6D6cp26qSXH6kUxaAa_71a3f3hVMT8vDNF3dpxXHp4D57TU2YoEKwGrflmA9jEQbtS4_qZ77eL5Ul-ragoAh9kBLgopvOU7WOWVanQFHbj8I", # "has_more": false # }In this example, you can see how the folder originally at
"/test/test_325818" was renamed to "/test/test_325818_renamed", but retained the same 'id' of "id:25N5ksooX-sAAAAAAAM5zg". - 7 years ago
Thank You Greg.
It really works for me.
Greg-DB
Dropbox Community Moderator
7 years ago[Cross-linking for reference: https://stackoverflow.com/questions/54417566/how-to-detect-dropbox-folder-is-renamed-via-dropbox-http-api-or-java-sdk ]
If a file or folder is renamed, the new entry will have the same 'id' as the previous (non-deleted) entry.
So, if you want to keep track of renames, you should keep the existing state, from the previous /2/files/list_folder and /2/files/list_folder/continue calls.
Here's a more complete example:
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/test_325818\"}" | jqp
# {
# "metadata": {
# "name": "test_325818",
# "path_lower": "/test/test_325818",
# "path_display": "/Test/test_325818",
# "id": "id:25N5ksooX-sAAAAAAAM5zg"
# }
# }
curl -X POST https://content.dropboxapi.com/2/files/upload \
--header "Authorization: Bearer <ACCESS_TOKEN>" \
--header "Dropbox-API-Arg: {\"path\": \"/test/test_325818/test_325818.txt\"}" \
--header "Content-Type: application/octet-stream" \
--data-binary "test data" | jqp
# {
# "name": "test_325818.txt",
# "path_lower": "/test/test_325818/test_325818.txt",
# "path_display": "/test/test_325818/test_325818.txt",
# "id": "id:25N5ksooX-sAAAAAAAM50A",
# "client_modified": "2019-01-29T19:08:37Z",
# "server_modified": "2019-01-29T19:08:37Z",
# "rev": "73c60021eccc7",
# "size": 9,
# "content_hash": "824979ede959fefe53082bc14502f8bf041d53997ffb65cbbe3ade5803f7fb76"
# }
curl -X POST https://api.dropboxapi.com/2/files/list_folder \
--header "Authorization: Bearer <ACCESS_TOKEN>" \
--header "Content-Type: application/json" \
--data "{\"path\": \"/test\",\"recursive\": true}" | jqp
# {
# "entries": [
# {
# ".tag": "folder",
# "name": "test",
# "path_lower": "/test",
# "path_display": "/test",
# "id": "id:25N5ksooX-sAAAAAAAM5zw"
# },
# {
# ".tag": "folder",
# "name": "test_325818",
# "path_lower": "/test/test_325818",
# "path_display": "/Test/test_325818",
# "id": "id:25N5ksooX-sAAAAAAAM5zg"
# },
# {
# ".tag": "file",
# "name": "test_325818.txt",
# "path_lower": "/test/test_325818/test_325818.txt",
# "path_display": "/test/test_325818/test_325818.txt",
# "id": "id:25N5ksooX-sAAAAAAAM50A",
# "client_modified": "2019-01-29T19:08:37Z",
# "server_modified": "2019-01-29T19:08:37Z",
# "rev": "73c60021eccc7",
# "size": 9,
# "content_hash": "824979ede959fefe53082bc14502f8bf041d53997ffb65cbbe3ade5803f7fb76"
# }
# ],
# "cursor": "AAEZHC5JNB-5N9UR8wHEdcHTUEbi-u78UPPhZfrt9hPLMhmbDIgPn6pFEmlMk7fItVUgMRA4dpMhLtwuqjlhTYgcDraWbCIpZ0rKJsPui2yTPXNIWIoCCjWzHm_osUCUWMOwGPLDqcXNMvhx5dUAz6fU7QaK0pGJAF08QdpQFV_KJC73PT1MT_DX1TYuDPBWkP4",
# "has_more": false
# }
curl -X POST https://api.dropboxapi.com/2/files/move_v2 \
--header "Authorization: Bearer <ACCESS_TOKEN>" \
--header "Content-Type: application/json" \
--data "{\"from_path\": \"/test/test_325818\",\"to_path\": \"/test/test_325818_renamed\"}" | jqp
# {
# "metadata": {
# ".tag": "folder",
# "name": "test_325818_renamed",
# "path_lower": "/test/test_325818_renamed",
# "path_display": "/Test/test_325818_renamed",
# "id": "id:25N5ksooX-sAAAAAAAM5zg"
# }
# }
curl -X POST https://api.dropboxapi.com/2/files/list_folder/continue \
--header "Authorization: Bearer <ACCESS_TOKEN>" \
--header "Content-Type: application/json" \
--data "{\"cursor\": \"AAEZHC5JNB-5N9UR8wHEdcHTUEbi-u78UPPhZfrt9hPLMhmbDIgPn6pFEmlMk7fItVUgMRA4dpMhLtwuqjlhTYgcDraWbCIpZ0rKJsPui2yTPXNIWIoCCjWzHm_osUCUWMOwGPLDqcXNMvhx5dUAz6fU7QaK0pGJAF08QdpQFV_KJC73PT1MT_DX1TYuDPBWkP4\"}" | jqp
# {
# "entries": [
# {
# ".tag": "deleted",
# "name": "test_325818.txt",
# "path_lower": "/test/test_325818/test_325818.txt",
# "path_display": "/test/test_325818/test_325818.txt"
# },
# {
# ".tag": "deleted",
# "name": "test_325818",
# "path_lower": "/test/test_325818",
# "path_display": "/Test/test_325818"
# },
# {
# ".tag": "folder",
# "name": "test_325818_renamed",
# "path_lower": "/test/test_325818_renamed",
# "path_display": "/Test/test_325818_renamed",
# "id": "id:25N5ksooX-sAAAAAAAM5zg"
# },
# {
# ".tag": "file",
# "name": "test_325818.txt",
# "path_lower": "/test/test_325818_renamed/test_325818.txt",
# "path_display": "/test/test_325818_renamed/test_325818.txt",
# "id": "id:25N5ksooX-sAAAAAAAM50A",
# "client_modified": "2019-01-29T19:08:37Z",
# "server_modified": "2019-01-29T19:09:03Z",
# "rev": "73c64021eccc7",
# "size": 9,
# "content_hash": "824979ede959fefe53082bc14502f8bf041d53997ffb65cbbe3ade5803f7fb76"
# }
# ],
# "cursor": "AAHt9Zlq5FimhWx0HZfGESi174eBTbSFXHS0ZyMQq5PcBgpWjIah3fS6iRKkyqHbmWr5MG-7cX4Bq8p6f6BF0nZ6D6cp26qSXH6kUxaAa_71a3f3hVMT8vDNF3dpxXHp4D57TU2YoEKwGrflmA9jEQbtS4_qZ77eL5Ul-ragoAh9kBLgopvOU7WOWVanQFHbj8I",
# "has_more": false
# }
In this example, you can see how the folder originally at
"/test/test_325818" was renamed to "/test/test_325818_renamed", but retained the same 'id' of "id:25N5ksooX-sAAAAAAAM5zg".
harshap
7 years agoHelpful | Level 6
Thank You Greg.
It really works for me.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!