cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox 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: 

Dropbox files/list_folder behaviour

Dropbox files/list_folder behaviour

Lechucico
Helpful | Level 6

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 3

Greg-DB
Dropbox Staff

[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.

Lechucico
Helpful | 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-DB
Dropbox Staff
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.
Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    Lechucico Helpful | Level 6
What do Dropbox user levels mean?