Forum Discussion

rafakato's avatar
rafakato
Explorer | Level 3
4 months ago

/files/list_folder do not return entries correctly when filtering

I'm developer of an app that uses Dropbox API to fetch folders from the root of user's account.
For most users the request works just fine, but there are some scenarios where a user have a lot of deleted files and folders in the root, in this scenario the API is not returning the entries correctly when filtering using `include_deleted=true` and `limit=100`, instead of excluding the deleted and returning the remaining entires up to the limit it returns only 1 entry, that is exactly the one that is not deleted from the first page of the request done with `include_deleted=false`, even using without limit it still fail to return all non-deleted entries in the first call, the user that raised this issue have 26 non-deleted folders in the root and 1 file, so it should be returned in just one page regardless of the limit, but the API apply the limit before the filterring.

Am I doing something wrong or is there a way to fix this?

3 Replies

Replies have been turned off for this discussion
  • iNeil's avatar
    iNeil
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    4 months ago

    Hi rafakato​,

    Due to various factors, the exact number of entries you receive per /2/files/list_folder or /2/files/list_folder/continue call can vary. It is not guaranteed to remain consistent over time, across accounts, folders, or parameter configurations.

    The /2/files/list_folder  endpoint itself is not guaranteed to return all results in a single API response, and there is no way to force it to do so. Therefore, you should always check the returned "has_more" value. If "has_more" is true, you need to call /2/files/list_folder/continue to retrieve the remaining results.

  • rafakato's avatar
    rafakato
    Explorer | Level 3
    4 months ago

    I understand it is not guaranteed to return all results, but what I'm saying is that the api apply first the limit then apply the filtering for deleted files.

    When I pass "include_deleted=false" and "limit=100" I get 100 items, but if I just change include_deleted to true, I get only 1 result that is exactly the only one in the first page that is not deleted

  • iNeil's avatar
    iNeil
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    4 months ago

    Hi rafakato​,

    When you use the "include_deleted=true" parameter with the /2/files/list_folder endpoint, it will include entries for files and folders that used to exist but were deleted, as well as those that still exist. It doesn’t filter out only deleted files and folders.

    Unfortunately there isn't a parameter that filters deleted files and folders with the /2/files/list_folder endpoint, but I'll pass this along as a feature request. I can't promise if or when that might be implemented though.

About Discuss Dropbox Developer and API

Node avatar for Discuss Dropbox Developer and API
Explore Dropbox Developer & API discussions with developers like you.

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!