We Want to Hear From You! What Do You Want to See on the Community? Tell us here!
Forum Discussion
AmitDori
8 years agoNew member | Level 2
Python SDK undocumented error on file_upload()
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
- Greg-DB8 years ago
Dropbox Community Moderator
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])))
- Greg-DB8 years ago
Dropbox Community Moderator
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).
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.6,036 PostsLatest Activity: 2 days ago
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
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!