We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here.
Forum Discussion
webrobert
2 years agoExplorer | Level 3
getting changes after Webhook
Hello devs,
I am having an issue getting changes to files [after changing to a business account]
Before I was using the `files/list_folder` endpoint.
But now I can't seem to get ...
- 2 years ago
Hi webrobert,
First of all, using list_folder alone, will never get the changes alone! Is this ever worked (on any account type)? I don't think so.
You need to keep the last cursor cached and when some change comes in, you can "continue" with changes only. 😉
webrobert wrote:...
I am having an issue getting changes to files [after changing to a business account]
...
Did you set your root namespace? 🤔 I can't see such things in the code you posted. Account root space and the home space coincide for personal account and for team account without spaces, but are different things when you're using team spaces. If not set explicitly, the home space is in use.
Hope this gives direction.
webrobert
Explorer | Level 3
@Здравко, legend. Thank you. Root name space. did it.
Yes, cache and go. Here is my Laravel solution using listFolderContinue() to retrieve or create a cache of the cursor.
public function listFolderContinue()
{
$cursor = cache()->rememberForever('dropbox_stores_cursor', function () {
return $this->listFolder()['cursor'];
});
$response = Http::withToken(cache()->get('dropbox_token'))
->withHeaders([
'Dropbox-API-Select-Admin' => '<member_id>',
'Dropbox-API-Path-Root' => '{".tag": "root", "root": "<id_of_root>"}'
])
->post('https://api.dropboxapi.com/2/files/list_folder/continue', compact('cursor'))
->json();
if ($response['cursor']) {
cache()->put('dropbox_stores_cursor', $response['cursor']);
}
return $response;
}
public function listFolder()
{
return Http::withToken(cache()->get('dropbox_token'))
->withHeaders([
'Dropbox-API-Select-Admin' => '<member_id>',
'Dropbox-API-Path-Root' => '{".tag": "root", "root": "<id_of_root>"}'
])
->post('https://api.dropboxapi.com/2/files/list_folder', [
'include_deleted' => true,
'include_has_explicit_shared_members' => false,
'include_non_downloadable_files' => false,
'path' => '/Stores',
'recursive' => true
])
->json();
}
Здравко
2 years agoLegendary | Level 20
Hi again webrobert,
Just to note some corner cases and some ways your code may get more stable.
Starting with listing and immediately continue that listing can lead to some inconsistencies at the beginning. If your initial listing "eat" the entire number of entries then the continuation wont return anything - the listing would already have processed all changes and you lost them. In opposite case - if you have too many files and the initial listing cannot get to all of them then many files will become recognized as changes while they are NOT actually - just entries left from the list.
Sometimes /2/files/list_folder/continue may not be able return any/all changes immediately. The changes aren't lost, but they will likely be returned on the next event - i.e. processing delay.
So to avoid any initialization issues, instead of within the processing body, better make the initial cache in your service initialization part and not using /2/files/list_folder, but rather jump to the end using /2/files/list_folder/get_latest_cursor. 😉 Isn't simpler? ... and stable!
You never check the 'has_more' flag! Check it out to avoid missing some entries, for variety of reasons, and do get in loop while this flag is set. In such a way there is no risk to delay processing of any entries.
Good luck.
About Discuss Dropbox Developer & API
Make connections with other developers
795 PostsLatest Activity: 7 days agoIf 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!