cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
We are making some updates so the Community might be down for a few hours on Monday the 11th of November. Apologies for the inconvenience and thank you for your patience. You can find out more 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: 

The Cursor of a user

The Cursor of a user

Malagann
Explorer | Level 3
Go to solution

Hello again.

After some searching, I'm back with another question that mirrors this one (https://www.dropboxforum.com/t5/API-Support-Feedback/Webhook-to-get-the-latest-changes-for-each-user...)

My webhook works, I get the json (list_folder/delta). My post request tests work with the token, I manage to search, get the list_folder, etc... But I have yet to link both as I cannot manage to find the cursor of a user.

I've search your forum and doc but no luck so far. I've read the aforementioned link but it's missing (or I'm too thick to find it ?) the one info I need. From the ID of a user, how do you retrieve his cursor ? (I'm in C#/asp.not webform). 

I'm looking to use list_folder/continue to get the infos on the change (the one that send the webhook).

 

Thanks, Malagann.

 

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

If the "entries" value is an empty list like you've shown here, it just means that there are no new entries to return for the cursor you supplied. (If the token or cursor were invalid, the API would respond with a specific error accordingly.)

Note that if you go through the /2/files/list_folder results and save the cursor after the webhook is received, there may not be any further results.

The basic flow typically looks like this:

  • the user connects to the app for the first time
  • the app starts listing the files and folders for the user using /2/files/list_folder and /2/files/list_folder/continue as necessary
  • the app stores the last returned cursor
  • the user leaves and some time passes
  • the user makes changes elsewhere
  • Dropbox sends the webhook notification for that user
  • the app recieves the webhook notification for that user and looks like up the last received cursor for that user
  • the app calls /2/files/list_folder/continue with that cursor to get the latest changes

View solution in original post

7 Replies 7

Greg-DB
Dropbox Staff
Go to solution

The Dropbox API does not offer a way to directly determine which cursor is for which user ID, or vice versa, based on just the cursors or tokens themselves. 

Instead, you need to store the asociation between the cursor and the user itself on your side. That is, when you receive a cursor and want to store it for later, key it by the account ID of the user. (You can do the same for the access token itself.) That way, when you receive the webhook notification with a particular account ID, you can look up the cursor and token for that particular user by looking up that account ID. (The exact data model you use is up to you of course, as that will depend on how your app works.)

Malagann
Explorer | Level 3
Go to solution

hello, thanks for taking the time !

The thing is, hence my question and issues, I don't know the cursor, do I ? I get the json of the notification when the webhook is activated with the dbID of the account and the IDs of the users but, before storing it and keying it with the appropriate ID, where can I find the cursor ? 

 

Greg-DB
Dropbox Staff
Go to solution

You should store the cursor for each user from your previous use of the API for each user. That might be from when the user first set up your app, or whenever they last used it, for instance. Specifically, it can be from the last time you called /2/files/list_folder or /2/files/list_folder/continue for that user. Each of those endpoints return a new cursor with the result.

Malagann
Explorer | Level 3
Go to solution

Me again, still lost. Sorry for the late answer.

I understand what you're saying but still cannot get with which end to start.

I've done some testing with cursors, with list_folder and list_folder/continue but get a different cursor everytime I use it with the same account so how do I exactly get THE cursor of the user when I get something different everytime ?

You're mentionning the "previous use of the API for each user" but how do I get the very first one, the very first time ? I receive the very first notification from my dropbox webhook, a file was deleted or added or moved (which ever case) and I want the info of list_folder/continue which requires a cursor.

I'd gladly associate the id of an user with its cursor but I still need somehow to find it the first time. Which is the last part of my problems. Is there an easy way in the api for it ? Or just a way for it ?

 

Anyways, I'd like to thank you again with your continued assistance.

 

 

 

Greg-DB
Dropbox Staff
Go to solution

There isn't a single cursor for each user. A cursor is way to keep track of "where" you are in the file listing, so it is expected to change over time (and even just for each call) for each user. You should continuously update the latest cursor you received for each user.

The first time you want to list the files and folders for a user, when you don't yet have a cursor for them, you should call /2/files/list_folder, which doesn't take a cursor as a parameter. The response will include a cursor, which you can then use with /2/files/list_folder/continue to then "pick up" where you left off with the previous call.

Malagann
Explorer | Level 3
Go to solution

So I had tried that and did it again. Saved the cursor and the _id after the webhook is recieved (thanks to list_folder) and then use the cursor with the list_folder/continue.

But the "entries" returnedwas empty

 

"entries": []

Does that mean the cursor isn't good ? The token ?

Anyway, I'll try again, differently. Thanks

Greg-DB
Dropbox Staff
Go to solution

If the "entries" value is an empty list like you've shown here, it just means that there are no new entries to return for the cursor you supplied. (If the token or cursor were invalid, the API would respond with a specific error accordingly.)

Note that if you go through the /2/files/list_folder results and save the cursor after the webhook is received, there may not be any further results.

The basic flow typically looks like this:

  • the user connects to the app for the first time
  • the app starts listing the files and folders for the user using /2/files/list_folder and /2/files/list_folder/continue as necessary
  • the app stores the last returned cursor
  • the user leaves and some time passes
  • the user makes changes elsewhere
  • Dropbox sends the webhook notification for that user
  • the app recieves the webhook notification for that user and looks like up the last received cursor for that user
  • the app calls /2/files/list_folder/continue with that cursor to get the latest changes
Need more support?
Who's talking

Top contributors to this post

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