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: 

Web-hook handling logic help

Web-hook handling logic help

gagsbh
Explorer | Level 4

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 1

Greg-DB
Dropbox Staff
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_ListFol...

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-f...
Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?