Cut the Clutter: Test Ignore Files Feature - sign up to become a beta tester here.
Forum Discussion
gagsbh
8 years agoHelpful | Level 5
Web-hook handling logic help
Hello Greg,
I need some help with using Web-hooks.
I use the following code to get a cursor token for the Root folder
Code I:
result = await client.Files.ListFolderGetLatestCursorAsync("",true);
and I save result.cursor in database.
Next time a web-hook arrives for the same dropbox account, I use the result.cursor previously saved in database to get the files changes
in Root folder, since the time I last saved the result.cursor token in database. I use the following code for this.
Code II:
ListFolderResult result2 = await client.Files.ListFolderContinueAsync(lstCursor); //lastCursor is read from database
var firstFile = result2.Entries.FirstOrDefault(i => i.IsFile);
if (firstFile != null)
{
//await Download(client, path, firstFile.AsFile);
}
I also update/save the result2.cursor in db so that next time the web-hook comes I use it to get the next set of changes since we got last file changes by using the following code:
Code III:
ListFolderResult result3 = await client.Files.ListFolderContinueAsync(lastCursor); //lastCursor ie. result2.cursor is read from database
var firstFile = result3.Entries.FirstOrDefault(i => i.IsFile);
if (firstFile != null)
{
//await Download(client, path, firstFile.AsFile);
}
I need to know whether my handling of web-hooks to get incremental file changes in Root folder is correct. (Please see Code I,II and III)
I am getting an exception while processing Case II:
The Exception is: Error in call to API function "files/list_folder/continue": Invalid "cursor" parameter:
Please help.
Thanks,
Gagan
1 Reply
- Greg-DB8 years ago
Dropbox Community Moderator
In your code for handling the ListFolderContinueAsync result, you appear to only be checking the first entry. That result can contain a large number of entries per page though, so this code could miss a significant number of entries. You should iterate through Entries to make sure you handle everything.
You can find more information on handling the Files.ListFolder* results in the documentation here:
https://dropbox.github.io/dropbox-sdk-dotnet/html/M_Dropbox_Api_Files_Routes_FilesUserRoutes_ListFolderAsync.htm
Regarding the cursor error, I see you have another thread for that, so I answered there:
https://www.dropboxforum.com/t5/API-Support-Feedback/Error-in-call-to-API-function-quot-files-list-folder-continue/m-p/282730#M17315
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.6,039 PostsLatest Activity: 2 days ago
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 or Facebook.
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!