Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
Lechucico
9 years agoHelpful | Level 6
Dropbox files/list_folder behaviour
Hello,
Actually I'm building an app that needs notifications when a file is created, modified or deleted. I have a webhook configured correctly.
I just need notifications about these files, not the entire dropbox.
I've tryed with /files/list_folder but it gives information of all files on a certain path and I don't want this behaviour.
I've seen get_lastest_cursor that gives information of only changes comparing the anterior cursor with the new cursor. I don't know how to use that, because on my java application I don't have this method avaiable:
DbxClientV2 dropboxClient = new DbxClientV2(config,<api_key>); result = dropboxClient.files().get_latest_cursor()??;
Is there any example of this? Is that what I need for receive the latest changes on dropbox?
Thanks.
3 Replies
- Greg-DB9 years ago
Dropbox Community Moderator
[Cross-linking for reference: https://stackoverflow.com/questions/45188338/dropbox-latest-changes-webhook ]
Dropbox webhooks will be sent for changes to any files your app can access in the linked users' accounts. It's not possible to configure them to be sent for only specific files, but I'll pass this along as a feature request.
Using listFolder and listFolderContinue, you can list all of the contents of the linked user's account. If you only want new changes though, you can use listFolderGetLatestCursor to get a cursor for the point in time at which you make the listFolderGetLatestCursor call. Then, you can call listFolderContinue again to get any changes that occurred after that point in time. (For example, you can call back using that cursor after you receive a webhook notification for that user.) Make sure you read the listFolder documentation for information on how to use this interface.
- Lechucico9 years agoHelpful | Level 6
But ListFolderGetLatestCursor needs a path too. I have to iterate over all folders for every user to see changes? There isn't any way of obtaining just the files that have changed?
I don't get how to just get the modifications, creations and deletions, because with that I have to iterate over all folders.
Webhook notifies when modified, created or deleted a file or folder. There isn't any way of obtaning that array of files on the webhook?
- Greg-DB9 years ago
Dropbox Community Moderator
The webhook itself doesn't tell you what has changed. It only tells you when something has changed.
You can certainly get just new changes after calling ListFolderGetLatestCursor though. It sounds like this is the process you're looking for:
1) Set up your webhook.
2) Call ListFolderGetLatestCursor with path="" (to indicate root, i.e., for all folders in the account that your app can see) and recursive=true (i.e., for all depths in those folders) and store the resulting cursor.
3) Wait for the webhook to notify you of changes.
4) When notified, call listFolderContinue using that stored cursor from step 2 to get only the things that have changed since then.
5) Store the new cursor returned by listFolderContinue. (Repeat if hasMore is true.)
6) Wait for further changes and repeat the loop.
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!