Im looking to download a CSV file that is on a shared dropbox folder. The code that I currently have given me an ApiError
. Full code and error below:
My Code:
import dropbox
ACCESS_TOKEN = '***MY ACCESS_TOKEN***'
dbx = dropbox.Dropbox(ACCESS_TOKEN)
url = "https://www.dropbox.com/sh/s8vwbg46zjsg3rw/AAC0T1BhIgfp5BfH_sJ_Vnb1a?dl=0"
file = "https://www.dropbox.com/sh/s8vwbg46zjsg3rw/AAC0T1BhIgfp5BfH_sJ_Vnb1a?dl=0&preview=Stock+List+2021-03-08.csv"
md, res = dbx.sharing_get_shared_link_file(url=file)
print(md)
print(res)
Error:
Traceback (most recent call last):
File "D:\***\PyCharm\Furniture\Test 1\dropbox_test.py", line 10, in <module>
md, res = dbx.sharing_get_shared_link_file(url=file)
File "C:\Python39\lib\site-packages\dropbox\base.py", line 4181, in sharing_get_shared_link_file
r = self.request(
File "C:\Python39\lib\site-packages\dropbox\dropbox_client.py", line 346, in request
raise ApiError(res.request_id,
dropbox.exceptions.ApiError: ApiError('90075839f9f94c53a112a48692314d4f', GetSharedLinkFileError('shared_link_is_directory', None))
Any help would be great. I have also tried files_download
and I also get an error.
The "https://www.dropbox.com/sh/s8vwbg46zjsg3rw/AAC0T1BhIgfp5BfH_sJ_Vnb1a?dl=0..." link itself points to a folder, not a particular file (whether or not you have the preview
parameter on it).
Here are two ways you can make this work:
path
parameter on sharing_get_shared_link_file
to specify the file in the folder you want:md, res = dbx.sharing_get_shared_link_file(url=url, path="/Stock List 2021-03-08.csv")
file = "https://www.dropbox.com/sh/s8vwbg46zjsg3rw/AABhEIN92e98iufhllgVuIvga/Stock%20List%202021-03-08.csv?dl=0"
md, res = dbx.sharing_get_shared_link_file(url=file)
Also, if the file is in the connected account for the access token you're using, you should certainly be able to use files_download
to download it. Feel free to open another question with the details of that issue if you wish.