cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
We are making some updates so the Community might be down for a few hours on Monday the 11th of November. Apologies for the inconvenience and thank you for your patience. You can find out more 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 (415) from Python files_upload API

Error (415) from Python files_upload API

ms97
Explorer | Level 3

Hello,

I am trying to write a python script to automatically store an excel file in dropbox.  My excel file is created from turning dataframes into excel sheets.  This file has 5 sheets with a different dataframe on each sheet. The file size is less than 150 MB.

 

The file shows up in my specified folder, but shows an Error (415) and cannot be opened or download.  The API gave no errors in my terminal when it ran.

 

Here is my code:

dbx.files_upload(output.read(), '/testfile3xlsx', mode=dropbox.files.WriteMode.overwrite)
 
where output is an excel sheet created using pd.ExcelWriter()

 

Thank you for your help!

9 Replies 9

Greg-DB
Dropbox Staff

Can you show where/how you're getting the 415 error? For instance, is that happening on the Dropbox web site? It may be helpful if you can share a screenshot of it. If it's on the web site, be sure to show the URL for context.

 

Also, if the files_upload method doesn't raise an error, it should return a value containing the metadata of the uploaded file, so it may be helpful context if you can print out and share that too.

ms97
Explorer | Level 3

Screenshot 2023-04-17 at 2.04.47 PM.png

I am seeing the 415 error when I try to open the file in the dropbox UI.  

 

Here is the metadata that was returned: 

FileMetadata(client_modified=datetime.datetime(2023, 4, 17, 16, 26, 35), content_hash='e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', export_info=NOT_SET, file_lock_info=NOT_SET, has_explicit_shared_members=NOT_SET, id='id:FgdW-Cdpb8oAAAAAAAAAGA', is_downloadable=True, media_info=NOT_SET, name='testfile3.xlsx', parent_shared_folder_id=NOT_SET, path_display='/testfile3.xlsx', path_lower='/testfile3.xlsx', preview_url=NOT_SET, property_groups=NOT_SET, rev='5f98aa794ffabe9475031', server_modified=datetime.datetime(2023, 4, 17, 16, 26, 35), sharing_info=NOT_SET, size=0, symlink_info=NOT_SET)

Здравко
Legendary | Level 20

Hi @ms97,

The metadata, you posted, shows that you have uploaded nothing. That's why an error appears. Hm.. 🤔 Such error can show a more useful message, but... Let's hope this will be improved and no so strange and confusing message gonna appear. 😁

Anyway, check what you're passing using 'output.read()' during your upload. As seems it's empty. 😉

Hope this gives direction.

Greg-DB
Dropbox Staff

@ms97 Здравко is correct; your output shows that your file upload was empty, which is why the Dropbox web site was not able to show the contents. You'll need to debug your integration to make sure you correctly upload the non-empty data.

credentially-dev-team
New member | Level 2

I am getting a similar response when just switching the folder I am uploading to:

FileMetadata(client_modified=datetime.datetime(2023, 8, 10, 16, 22, 13), content_hash='e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', export_info=NOT_SET, file_lock_info=NOT_SET, has_explicit_shared_members=NOT_SET, id='id:MfcxP9MMQyMAAAAAAAAAHg', is_downloadable=True, media_info=NOT_SET, name='test.zip', parent_shared_folder_id=NOT_SET, path_display='/Folder2/test.zip', path_lower='/folder2/test.zip', preview_url=NOT_SET, property_groups=NOT_SET, rev='0160293ffb9dc8f0000000104e641f1', server_modified=datetime.datetime(2023, 8, 10, 16, 22, 14), sharing_info=NOT_SET, size=0, symlink_info=NOT_SET)

So my problem has nothing to do with the file itself because it has been uploaded into another folder successfully:

FileMetadata(client_modified=datetime.datetime(2023, 8, 10, 16, 28, 4), content_hash='e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', export_info=NOT_SET, file_lock_info=NOT_SET, has_explicit_shared_members=NOT_SET, id='id:qzdXOVVbA8AAAAAAAAUJ_w', is_downloadable=True, media_info=NOT_SET, name='test.zip', parent_shared_folder_id='4391826353', path_display='/Folder1/test.zip', path_lower='/folder1/test.zip', preview_url=NOT_SET, property_groups=NOT_SET, rev='016029414a2b7250000000105c5f3b1', server_modified=datetime.datetime(2023, 8, 10, 16, 28, 4), sharing_info=FileSharingInfo(modified_by='dbid:AAB_CoHtiOlASmyE9l1g_5pdrDuPG1s2CIQ', parent_shared_folder_id='4391826353', read_only=False), size=0, symlink_info=NOT_SET)

What do you think it could be?

 

Greg-DB
Dropbox Staff

@credentially-dev-team Both samples you shared here show 'size=0', meaning that both files were uploaded with empty contents. Please check your upload code to make sure you're uploading the non-empty contents that you expect for the files.

Здравко
Legendary | Level 20

@credentially-dev-team wrote:

...

FileMetadata(..., size=0, ...)

So my problem has nothing to do with the file itself because it has been uploaded into another folder successfully:

FileMetadata(..., size=0, ...)

What do you think it could be?


Hi @credentially-dev-team,

I think you cannot read those empty archives content in both cases. 🙋

credentially-dev-team
New member | Level 2

@Здравко

 

Yes, but still. Via UI I can see the file in Folder1 so it turns out empty files can be uploaded 🙂

Greg-DB
Dropbox Staff

@credentially-dev-team Dropbox allows you to upload empty files (that is, files with size of 0), but empty files are not valid zip files.

Need more support?