cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Share your feedback on the Document Scanning Experience in the Dropbox App right 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: 

Webhook notification .NET

Webhook notification .NET

Babel3d
New member | Level 2
Go to solution


Hello,

I am working on a .NET app, which is integrated with the dropbox api. I managed to upload, list, delete files without any problems. Now, I am trying to use webhooks for my app. I have a dedicated dropbox account which linked to my app and this account has "full access" to my dropbox storage.
We want Dropbox to notify my app when files are added or deleted. After going through documentation [https://www.dropbox.com/developers/reference/webhooks#tutorial], I am managed to get webhook trigger on file add/delete of a file in my storage using ListFolderContinue API. So far so good.

 

Here is mode code snippet

//---------------------------------
var cursor = getPreviousCursor( user);  // to get previously stored cursor
using (var client = new DropboxClient(accessToken))
{
 ListFolderResult list = await client.Files.ListFolderContinueAsync(cursor);
 bool bHasMore = true;
    while (bHasMore)
    {
        foreach (var entry in list.Entries)
        {
            if (entry.IsDeleted || entry.IsFolder)
                continue;
            string fname = entry.Name;
        }
        cursor = list.Cursor;
        bHasMore = list.HasMore;
        UpdateCursor(user, cursor); // to store latest cursor
    }
}
//--------------------------------

 

 

Now here comes the problem that I am facing.
Above code works only if I modify files in root folder ("/") folder of the dropbox storage. If I modify a file in a folder e.g. "/Sample/Project/test.txt", I receive webhook trigger but "ListFolderResult list" is always empty.

To sumarize I am not getting information of modified files in the folders except root folder of dropbox storage.

Please help.

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution
By default, the listFolder/listFolderContinue methods will only return items in the folder you specify, and not in nested folders under that.

If you want nested results, you'll need to set recursive=true when first calling listFolder:

https://dropbox.github.io/dropbox-sdk-dotnet/html/M_Dropbox_Api_Files_Routes_FilesUserRoutes_ListFol...

View solution in original post

7 Replies 7

Greg-DB
Dropbox Staff
Go to solution
By default, the listFolder/listFolderContinue methods will only return items in the folder you specify, and not in nested folders under that.

If you want nested results, you'll need to set recursive=true when first calling listFolder:

https://dropbox.github.io/dropbox-sdk-dotnet/html/M_Dropbox_Api_Files_Routes_FilesUserRoutes_ListFol...

Babel3d
New member | Level 2
Go to solution

Thanks. It worked.

pcuycs
Explorer | Level 3
Go to solution

hi @Babel3d , @Greg-DB 
I'm working with dropbox webhook using asp.net api
I was created 2 uri, one for verify, another for received response message from dropbox and both are successfully.
the response message content
{"list_folder": {"accounts": ["dbid:yyyyyyyyyyyyy"]}, "delta": {"users": [xxxxxxxxxxxx]}}

But with above message
1. I don't know what are type of notifications raised? Add, Modified, Moved, Deleted -> at files & folders level ?
2. How do i know what is the file name and who has changed?
3. what does [xxxxxxxxxxxx] mean?

thanks for help!

Greg-DB
Dropbox Staff
Go to solution

@pcuycs I recommend reviewing the webhooks tutorial and documentation (be sure to switch to the "documentation" tab for that) as it covers this in detail: 

https://www.dropbox.com/developers/reference/webhooks 

To answer your specific questions though:

  1. Webhook notifications are sent for any kind of file/folder changes.
  2. The notifications themselves don't indicate what changed, only that something changed. You need to call the list_folder endpoints to determine what changed. 
  3. The "xxxxxxxxxxxx" in your sample is the old API v1 style of user IDs. You do not need to use it. It conveys the same information as the new API v2 style (e.g., "dbid:yyyyyyyyyyyyy" in your sample) which you should use.

pcuycs
Explorer | Level 3
Go to solution

thanks @Greg-DB 
I read it,
I store the latest cursor and deleted 1,2.. files on the dropbox, but when used postman to call https://api.dropboxapi.com/2/files/list_folder/continue api, i don't see any entries item
What have i done wrong?
image link: http://prntscr.com/mroei2

 

Greg-DB
Dropbox Staff
Go to solution

@pcuycs We'll need some more information to help troubleshoot this issue. Please open a new thread with additional details so we can help with this. Specifically, please share:

  • the request and response for /2/files/list_folder
  • information about where/how you deleted the files
  • the webhook notification
  • the request and response for /2/files/list_folder/continue 

Be sure to redact the access token of course. 

pcuycs
Explorer | Level 3
Go to solution

hi @Greg-DB 
it worked for me, mabe i mistake app token.
thanks

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    pcuycs Explorer | Level 3
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?