We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here.

Forum Discussion

Thang2000's avatar
Thang2000
Explorer | Level 4
2 years ago

Search files in folder based on file tags python sdk

I'm trying to search files in a folder based on file tag, python SDK, yet encountering an error when trying to use my folder path:

 

 

from dropbox.files import SearchOptions

# search_op = SearchOptions() # this works but gives me everything from master folder
search_op = SearchOptions(path="/Thang Nguyen/Nano/Photos/Appurtenances/", max_results=10)

dm = dbx.files_search_v2(query="significant", options=search_op)

 

 

 

 

 raise BadInputError(request_id, res.text)
dropbox.exceptions.BadInputError: BadInputError('58ddfa8a32824ea9b8e80882f2ef3a59', 'Error in call to API function "files/search_v2": invalid_argument')

 


Also, right now I'm passing in "query" and I'm assuming that would retrieve all files associate with "significant" keyword. How do I specify to search by tags only? Any code example would be a great help.

I also need to implement this function in Java.

  • Здравко's avatar
    Здравко
    Legendary | Level 20

    Thang2000, you're getting that error because you have passed invalid argument - path in Dropbox (to either file or folder) cannot end in slash! That's it.

    Hope this helps.

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    Thang2000 As Здравко said, the error you're getting is because of the extra "/" you have at the end of your "path" value. Remove that extra slash to get that to work.

     

    The Dropbox Java SDK offers the same search functionality.

     

    As for searching by tags only, unfortunately the Dropbox API (regardless of which SDK you're using, if any) doesn't currently offer an option for restricting the search to match tag values only, but I'll pass this along as a feature request. I can't promise if or when that might be implemented though.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,877 PostsLatest Activity: 3 hours ago
325 Following

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 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!