Need to see if your shared folder is taking up space on your dropbox 👨‍💻? Find out how to check here.

Forum Discussion

vineet's avatar
vineet
Explorer | Level 3
6 years ago
Solved

webhooks notification

we have reviced the notification json format, but how can get actual file chnages.

  • When you first store the access tokens and cursors in your app (e.g., in your database), you should record which Dropbox account ID each one belongs to. (For any given access token, you can use /2/users/get_current_account to check the account ID, which just needs to be done once each.)

     

    Then, when you get the webhook notification, you can use the account ID to look up the corresponding access token and cursor.

9 Replies

Replies have been turned off for this discussion
  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    6 years ago

    The webhook notification payload will tell you which account has had changes, so you can then use the corresponding access token for that account to call /2/files/list_folder[/continue] (or corresponding methods in whatever SDK/library you're using, if any) to see what exactly changed.

  • vineet's avatar
    vineet
    Explorer | Level 3
    6 years ago

    We are using from postman  https://api.dropboxapi.com/2/files/list_folder/get_latest_cursor 

     parameter 

    {"path""","recursive"true,"include_media_info"false,"include_deleted"false,"include_has_explicit_shared_members"false,"include_mounted_folders"false,"include_non_downloadable_files"true}
     
    response is getting 
    {
        "cursor""AAEbjtW3suBBNRBPGmOMSPj69WGB4_TV4EkxUdP2r_W3uI4SuAsMX7tdrFy9UQ-s8ZC74h8HNo_0f6mGTXqx8zUA_gkjGsh9aZ7o6ch-wTbG-1eXrJtoMrXS5nkG2oIYFAhUxApWIpTB9OkiFewCgw3Ar5MgJRfZ6b2WuIhoJ5vYe8Txb-_N-sMapbzUh5DiZVhyoTeT-76BwIZX_7XEoAgr1CmnxA1HJQfqVpY9Fip5dA"
    }
     
    after the response API , we are using second API   https://api.dropboxapi.com/2/files/list_folder/continue for get the latest changes
    request 
    {"cursor""AAEbjtW3suBBNRBPGmOMSPj69WGB4_TV4EkxUdP2r_W3uI4SuAsMX7tdrFy9UQ-s8ZC74h8HNo_0f6mGTXqx8zUA_gkjGsh9aZ7o6ch-wTbG-1eXrJtoMrXS5nkG2oIYFAhUxApWIpTB9OkiFewCgw3Ar5MgJRfZ6b2WuIhoJ5vYe8Txb-_N-sMapbzUh5DiZVhyoTeT-76BwIZX_7XEoAgr1CmnxA1HJQfqVpY9Fip5dA"}
     
     
     
    response
    {
        "entries": [],
        "cursor""AAFtk_vDugrNpHMohiYXcyZi0NpVVlc79RjfB7M5Zu7zfI0DojtbSf3Yw8pah-oqBda83532H7G2GoEXP_e2UrWwvCaZAWcHysfkfuOll9sZntVn2TYMem84VMa_CQpKZMpyYvMFZwi3OMgnMtRUwZ_t1yRGAyPbuBf6P9NkuEpkf6Qzqbc-JRPvJwlip03iI18E-_NZmYcsuaRw6zpWvDyBTZCwKBvSwoa0c9C-bClHJhSe_G5AHLDw2O_nYyv9plM",
        "has_more"false
    }
     
    We have  change the folder name and file name  and munual file upload on dropbox , current get the reciving the  notification like this 
    {"list_folder": {"accounts": ["dbid:AADsKehzrQqxnG4GnclQAYU2mU0ER_f9vOw"]}, "delta": {"users": [2399690544]}}
     
    i am using current linked account access token form APP console,
     
    did't get any latest chnages  file and folder after the hiting  https://api.dropboxapi.com/2/files/list_folder/continue did not get any resoonse everytime getting  response is empty like this 
    {
        "entries": [],
        "cursor""AAFtk_vDugrNpHMohiYXcyZi0NpVVlc79RjfB7M5Zu7zfI0DojtbSf3Yw8pah-oqBda83532H7G2GoEXP_e2UrWwvCaZAWcHysfkfuOll9sZntVn2TYMem84VMa_CQpKZMpyYvMFZwi3OMgnMtRUwZ_t1yRGAyPbuBf6P9NkuEpkf6Qzqbc-JRPvJwlip03iI18E-_NZmYcsuaRw6zpWvDyBTZCwKBvSwoa0c9C-bClHJhSe_G5AHLDw2O_nYyv9plM",
        "has_more"false
    }
     
     
    please suggest me where i am worng
     
     
     
     
     
     

     

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    6 years ago

    To clarify, are you calling /2/files/list_folder/get_latest_cursor before or after you received the webhook notification?

     

    The order should look like this:

     

    1. Call /2/files/list_folder/get_latest_cursor to get the latest cursor for the account using the access token for the account and save the returned cursor.
    2. Make changes in the account.
    3. Receive the webhook notification from Dropbox for the account.
    4. Call /2/files/list_folder/continue using the cursor received in step 1 and the same access token.
  • vineet's avatar
    vineet
    Explorer | Level 3
    6 years ago

    Thnaks,  for the fast response 

     

    i want to  ask question 
    we have recived Cursor response from Get lateat cursor API  and save cursor data into database  and 

    I have recived the notification and the save the notification json format into database 

     

    How can get  User details from which API

     

    {"list_folder": {"accounts": ["dbid:AADsKehzrQqxnG4GnclQAYU2mU0ER_f9vOw"]}, "delta": {"users": [2399690544]}}

     

    please suggest me 

     

     

     

     

     

     

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    6 years ago

    When you first store the access tokens and cursors in your app (e.g., in your database), you should record which Dropbox account ID each one belongs to. (For any given access token, you can use /2/users/get_current_account to check the account ID, which just needs to be done once each.)

     

    Then, when you get the webhook notification, you can use the account ID to look up the corresponding access token and cursor.

  • vineet's avatar
    vineet
    Explorer | Level 3
    6 years ago

    Thanks for the response Greg

     

    Can i use GetAccount API , i got the response dbId for reciving notification and pass the parameter dbId into GetAccount API  so getting the response for particular user???

     

    ???????

     

     

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    6 years ago

    You can technically use /2/users/get_account to look up the account information for a particular account based on an account ID, but for the sake of efficiency I recommend instead recording the information initially as described in my previous comment.

  • RJ77's avatar
    RJ77
    New member | Level 2
    4 years ago

    Followed the exact steps still getting entries=[]

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    4 years ago

    RJ77 The webhook notification indicates that the account has had changes somewhere in the account, so you can then use the corresponding access token for that account to call /2/files/list_folder[/continue] (or corresponding methods in whatever SDK/library you're using, if any) to see what exactly changed.

     

    So, make sure you're using an access token for the correct account. Also, note that the calls to /2/files/list_folder[/continue] will be subject to the options you set (or their defaults, if you don't specifically set them) when calling /2/files/list_folder. Returned cursors retain those options. For example, if you set 'recursive=false' (or didn't set 'recursive'), and the changed item(s) were nested deeper than the 'path' you listed, you won't get those entries returned in the 'entries' list. You would need to set 'recursive=true' in that case to get those entries (or explicitly list the relevant parent folder). I recommend referring the documentation linked above as well as the File Access Guide and Detecting Changes Guide.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.

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, Facebook or Instagram.

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!