You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.

Forum Discussion

af11's avatar
af11
Explorer | Level 4
3 years ago

not getting data for edits in folders

Hi,

I set up a notification system to get notified when there are changes to my dropbox account.  

The following is a code excerpt

def process_user(account):

# cursor for the user (None the first time)
cursor = redis_client.hget('cursors', account)

dbx = Dropbox(ACCESS_TOKEN)

has_more = True

while has_more:
if cursor is None:
result = dbx.files_list_folder(path='', recursive=True)
print(f'RESULT WHEN CURSOR WAS NONE: {result}')
else:
result = dbx.files_list_folder_continue(cursor)
print(f'RESULT WHEN WAS CURSOR: {result}')

for entry in result.entries:
print(entry)
send_notification('entry')

# Update cursor
cursor = result.cursor
redis_client.hset('cursors', account, cursor)

# Repeat only if there's more to do
has_more = result.has_more

However, when I make edits to data in folders, this is what files_list_folder_continue returns: 

ListFolderResult(cursor='AAFZsPF8zLH6ZKF2EXhPnqhXR5OhP-0ydWr8wx3hph4byo7wTdJytQCwIY7x8JeXI01j1x417_VNyrOrFmNyx8-CUghuHeCxrrkZZXRmMBgStDBJy-XEqKEeXIcyJ0iMvxdSI_hnDPdRcvEL1esHLHr5L1JYjx9RLis8nNqWG_MJH4dwjWZd3hJIM2hTGHSV_1A', entries=[], has_more=False)


 The entry array is empty.  How am I supposed to know what was edited?  What can I change so that I get the data for edits in folders?

 

Thank you

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    Webhook notifications tell you when something has changed, and using the files_list_folder/files_list_folder_continue functionality is the right way to then list items and check for changes.

     

    In this case, I see you're getting back a result with an empty entries list, indicating that there were no changes to report for the supplied cursor. Webhook notifications will be sent for any changes, but the entries that the files_list_folder/files_list_folder_continue functionality returns will depend on the parameters you used with them originally. From your files_list_folder call I see you're passing in the empty string as the path and are setting recursive=True. Note that by default though, API calls operate in the "member folder" of the connected account, so anything outside the member folder, such as in the "team space", if any, will not be found by default. You can configure API calls to operate in the "team space" instead though. To do so, you'll need to set the "Dropbox-Api-Path-Root" header. You can find information on this in the Team Files Guide.

    • af11's avatar
      af11
      Explorer | Level 4

      The thing is that I am testing this app on a personal account for now so the team members is not the issue.

      There are changes being made when the Webhook returns an empty entry.

      Could it be that the issue is that I only set the recursive property later on, after I had been running the code a few times?

      Can you please advise?

      Thank you

      • Greg-DB's avatar
        Greg-DB
        Icon for Dropbox Staff rankDropbox Staff

        This would depend on the particular timing and cursors you're using, but yes, the options you set on files_list_folder apply to the cursor resulting from that call, as well as all further cursors retrieved from that initial cursor. So, for example, if you are using a cursor that descends from a call that originally set 'recursive=False' (or omitted 'recursive', since the default is 'False), then you will not receive any nested entries when using that cursor (or any such descendant cursor). You would need to start again with files_list_folder to change the options.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,910 PostsLatest Activity: 2 days ago
333 Following

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!