adam adam - 8 months ago 36
Java Question

Dropbox API Cursors: how long are they valid for and using them properly over time

I've been testing the list files API (still using a development account, maybe that's part of the problem?), but seeing unexpected results. Basically, I ask info on a path, process the results, and then ask for a "new" cursor via "listFolderGetLatestCursor" but it says there are no changes. Am I missing something?

Question: How long is a cursor valid for?

Problem: If I run the following method with a

cursor in path
and set aside the cursor as
and then modify files in
and then run the same method with
after 1 day, getting back
it doesn't show any changes. Sometimes, I seem to get expected results when I run it in shorter time-intervals, but I must be missing something.

public String doDropboxWork(String path, String cursor) {
// make request for path
if (cursor == null) {
ListFolderBuilder listFolderBuilder = client.files().listFolderBuilder(path);
result = listFolderBuilder.withRecursive(true).withIncludeDeleted(false).start();
} else {
result = client.files().listFolderContinue(cursor);

while (true) {
// ... do work ....
if (!result.getHasMore()) {
result = client.files().listFolderContinue(result.getCursor());

// get new cursor
String cursor2 = client.files().listFolderGetLatestCursor(path).getCursor();
return cursor2;

thanks in advance


based on feedback from the Dropbox Forum, the fix is to not ask for a new cursor:

//String cursor2 = client.files().listFolderGetLatestCursor(path).getCursor();

as this resets the polling