cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox 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: 

Re: Error downloading files from dropbox API

Error downloading files from dropbox API

pyraxic
Helpful | Level 6
Go to solution

I am trying to download files from dropbox but keep hitting the ValidationError.

 

for dfiles in flist:
        dbx.files_download_to_file('/Users/fela/Downloads/dropbox', dfiles, rev=None)

Here is the error:

ValidationError at /dropbox_auth_finish
'2005-02-15 00.39.15-2.tif' did not match pattern '(/(.|[\r\n])*|id:.*)|(rev:[0-9a-f]{9,})|(ns:[0-9]+(/.*)?)'
Request Method:	GET
Request URL:	https://localhost:8000/dropbox_auth_finish?state=fNWCqBEYwxETbqJU-N5zlA%3D%3D&code=wPfEvSKsCIEAAAAAAAAZdQWDsobxTQufArgHJU7is
Django Version:	1.11.3
Exception Type:	ValidationError
Exception Value:	
'2005-02-15 00.39.15-2.tif' did not match pattern '(/(.|[\r\n])*|id:.*)|(rev:[0-9a-f]{9,})|(ns:[0-9]+(/.*)?)'
Exception Location:	/Users/fela/miniconda3/envs/clauks/lib/python3.6/site-packages/dropbox/stone_validators.py in validate, line 317
Python Executable:	/Users/fela/miniconda3/envs/clauks/bin/python
Python Version:	3.6.2

 

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

You do need to use the full path when specifying the file you want to download. Using files_list_folder and files_list_folder_continue will give you every entry, and you can get the full path from the returned (File)Metadata.path_lower. (I.e., use `entry.path_lower` instead of `'/'+entry.name`.)

View solution in original post

10 Replies 10

pyraxic
Helpful | Level 6
Go to solution

Seems like I was missing a leading "/" from my command but now it gives another error.

 

for dfiles in flist:
        dbx.files_download_to_file('/Users/fela/Downloads/dropbox/'+dfiles, '/'+dfiles, rev=None)

Error:

ApiError at /dropbox_auth_finish
ApiError('41b9e1718f4f92d51231197741ac31d5', DownloadError('path', LookupError('not_found', None)))
Request Method:	GET
Request URL:	https://localhost:8000/dropbox_auth_finish?state=NSz1ObeJgWL234R2kIXBMw%3D%3D&code=wPfEvSKsCIEAAAAAAAAZi9WtSCRKLq18aMUUfGQJY
Django Version:	1.11.3
Exception Type:	ApiError
Exception Value:	
ApiError('41b9e1718f4f92d51231197741ac31d5', DownloadError('path', LookupError('not_found', None)))
Exception Location:	/Users/fela/miniconda3/envs/clauks/lib/python3.6/site-packages/dropbox/dropbox.py in request, line 256
Python Executable:	/Users/fela/miniconda3/envs/clauks/bin/python
Python Version:	3.6.2

pyraxic
Helpful | Level 6
Go to solution

I figured it out. It seems that I need to enter the remote path name. For example, if I have a folder named "Camera", it should use /Camera/filename. But how do I get the list of folder name and files under that folder name (if I have multiple folders)? I could use files_list_folder which gives me the list of files but how can I get the hierarchy (folder structure)?

Greg-DB
Dropbox Staff
Go to solution

That's correct, the `path` parameter value for files_download_to_file should be the full remote (Dropbox) path of the file you want to download.

 

Using files_list_folder is the right way to list files and folders under any particular path. (Use the empty string "" as the path for root if that's what you're looking for.) 

 

If you want to list everything, included nested items, set recursive=true. Either way, be sure to check the resulting ListFolderResult.has_more to see if you need to call back to files_list_folder_continue to get more results.

pyraxic
Helpful | Level 6
Go to solution

Here is my code.

 

dbx = dropbox.Dropbox(oauth_result.access_token)
    result = dbx.files_list_folder("", recursive=True)
    flist = []

    def process_entries(entries):
        for entry in entries:
            if isinstance(entry, dropbox.files.FileMetadata):
                flist.append(entry.name)
                dbx.files_download_to_file('/Users/fela/Downloads/dropbox/'+entry.name, '/'+entry.name)

It gives me an error:

ApiError('9102ee3554ff1ef69453c208accc6568', DownloadError('path', LookupError('not_found', None)))

 Unless I use "/Camera". As you can see that I am using "" with recursive=True to go through the entire dropbox and list files. I am not able to download it unless I specify the folder name. How can I get the folder structure and files under them so I can download files from the root folder and all the subfolders under them?

Greg-DB
Dropbox Staff
Go to solution

You do need to use the full path when specifying the file you want to download. Using files_list_folder and files_list_folder_continue will give you every entry, and you can get the full path from the returned (File)Metadata.path_lower. (I.e., use `entry.path_lower` instead of `'/'+entry.name`.)

pyraxic
Helpful | Level 6
Go to solution

Awesome! That works. Thank you

rhernandez8305
Helpful | Level 6
Go to solution

this example (Download file), do you have in github or similar plataform?

pyraxic
Helpful | Level 6
Go to solution

I don't have an example but if you follow the documentation from dropbox, it should walk you through it.

Need more support?