cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements
Update: Find information on Dropbox support during COVID-19 here
Close
cancel
Showing results for 
Search instead for 
Did you mean: 

Python SDK undocumented error on file_upload()

AmitDori New member | Level 2
New member | Level 2

Hi all,

I'm having troubles uploading files using the file_upload method using Python's dropbox module.

I've setup an app(giving it full access to my dropbox account, not just folder access) and created an AUTHSTRING for my python code to use.

 

Important thing to note is, I'm trying to upload a file with custom properties - I know its not very well documented (took me quite some time to figure out what i need) but still:

 

import dropbox

#setting up a new template
client = dropbox.Dropbox("AUTHSTRING")
template = dropbox.file_properties.PropertyFieldTemplate(name="MySig", description="signature",type=dropbox.file_properties.PropertyType("string"))
TEMPLATE_ID = client.file_properties_templates_add_for_user("MySig","signature",[template]).template_ids[0]

#setting up a property
property = dropbox.file_properties.PropertyGroup(template_id = TEMPLATE_ID , fields = [dropbox.file_properties.PropertyField(name="MySig",value="siggggg")])

#reading the file
with open("FILENAME","rb") as f:
 file = f.read()

#uploading the file
client.files_upload(file, "FILEPATH", mode = dropbox.files.WriteMode('overwrite', None), mute=True, property_groups=[property])

The file is succesfully uploaded to my dropbox(!) but I'm getting this wierd, poorly detailed error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\site-packages\dropbox\base.py", line 2076, in files_upload
    f,
  File "C:\Python27\lib\site-packages\dropbox\dropbox.py", line 234, in request
    timeout=timeout)
  File "C:\Python27\lib\site-packages\dropbox\dropbox.py", line 325, in request_json_string_with_retry
    timeout=timeout)
  File "C:\Python27\lib\site-packages\dropbox\dropbox.py", line 414, in request_json_string
    raise InternalServerError(request_id, r.status_code, r.text)
dropbox.exceptions.InternalServerError: InternalServerError('a4d3cc2568a71f11f1d800c58cf011d1', 500, u'')

Can anyone explain what's going on here?

 

I wouldn't mind the error if the file was indeed uploaded with the property I've assigned, but unfortunately, it has no properties:

FileMetadata(name=u'FILENAME', id=u'FILEID', client_modified=datetime.datetime(2017, 11, 21, 12, 24, 43), server_modified=datetime.datetime(2017, 11, 21, 12, 24, 43), rev=u'96bb064e0', size=18490, path_lower=u'/FILENAME', path_display=u'/FILENAME', parent_shared_folder_id=None, media_info=None, sharing_info=None, property_groups=None, has_explicit_shared_members=None, content_hash=u'FILEHASH')

 

Notice the property_groups = None

 

Any help would be appreciated!

Thanks in advance!

Amit.

2 Replies 2

Re: Python SDK undocumented error on file_upload()

Dropboxer
Dropboxer

Thanks for the report! An InternalServerError can occur on any call, and just indicates that something failed on our side. When this occurs, the API doesn't return much information to the client, so you'll only get that error without any useful details. We're looking into this particular error, and I'll follow up here once I have an update on it for you.

 

For reference though, based on what I can see, it looks like there was something incorrect about the property you're trying to set. It looks like it may have been modified in the version of the code you set, but for example, make sure you specify the correct/exact field name.

 

By the way, to retrieve the metadata including the property groups, you'd need to call like this:

 

print(client.files_get_metadata("FILEPATH", include_property_groups=dropbox.file_properties.TemplateFilterBase.filter_some([TEMPLATE_ID])))

Re: Python SDK undocumented error on file_upload()

Dropboxer
Dropboxer

With the latest version of the Python SDK (currently 8.5.1) you should now receive a specific error when you try to set an incorrect property value (e.g., using the wrong field name).

Work Smarter with Dropbox

The way we work is changing. Share and discover new ways to work smarter with Dropbox in our community.

Sound good? Let's get started.
Who's talking

Top contributors to this post

What do Dropbox user levels mean?
Need more support?