We’re Still Here to Help (Even Over the Holidays!) - find out more here.
Forum Discussion
ADoncel
6 years agoExplorer | Level 4
file_properties_properties_add() - InternalServerError('', 500, '')
Hello,
I'm using Python 3.6 and Dropbox API installed with pip under Linux 4.4.0-18362-Microsoft #476-Microsoft Fri Nov 01 16:53:00 PST 2019 x86_64 x86_64 x86_64 GNU/Linux (WSL Ubuntu).
I...
- 6 years ago
Thanks! It looks like there's just a small issue in that code. The file_properties_properties_add method expects a list of 'PropertyGroup', so instead of:
dbx_api.file_properties_properties_add(p_target_file, property_group)
you should do:
dbx_api.file_properties_properties_add(p_target_file, [property_group])
ADoncel
6 years agoExplorer | Level 4
Hello,
Thank you very much for the answer.
I didn't one PropiertyGroup with more than one field because in that case this error raises:
Exception has occurred: ValidationError - PropertyGroup(template_id='ptid:iMdPSELQckAAAAAAAAAAIQ', fields=[PropertyField(name='date', value='1548965874'), PropertyField(name='park', value='x'), PropertyField(name='attraction', value='y'), PropertyField(name='file_type', value='video'), PropertyField(name='uid', value='AS46561sdg99wrDSD9e6f1e')]) is not a valid list.
Due to this, I was passing a list of PropertyGroup, one for each field I need to write and I get the 500 error, so I'm stuck here.
This is what I do to create everything in case there is something wrong here:
self.dbx_api = dropbox.Dropbox(self.token, timeout=p_timeout)
# Confirm the access token is valid:
try:
self.dbx_api.users_get_current_account()
except dropbox.exceptions.AuthError:
sys.exit("ERROR: Invalid access token; try re-generating an access token from the app console on the web or asking to you System Administrator")
string_t = dropbox.file_properties.PropertyType.string
date = dropbox.file_properties.PropertyFieldTemplate(
'date',
'Date when the file was upload',
string_t)
park = dropbox.file_properties.PropertyFieldTemplate(
'park',
'Park where the media was done',
string_t)
attraction = dropbox.file_properties.PropertyFieldTemplate(
'attraction',
'Attraction where the media was done',
string_t)
f_type = dropbox.file_properties.PropertyFieldTemplate(
'file_type',
'Type of file (video/photo)',
string_t)
uid = dropbox.file_properties.PropertyFieldTemplate(
'uid',
'Uniq identifier for the object',
string_t)
template = self.dbx_api.file_properties_templates_add_for_user(
'media_file',
'Properties for media files (photos/videos)',
[date, park, attraction, f_type, uid])
self.template_id = template.template_id
date_property = dropbox.file_properties.PropertyField('date', p_date)
park_property = dropbox.file_properties.PropertyField('park', p_park)
attraction_property = dropbox.file_properties.PropertyField('attraction', p_attraction)
f_type_property = dropbox.file_properties.PropertyField('file_type', p_f_type)
uid_property = dropbox.file_properties.PropertyField('uid', p_uid)
property_group = dropbox.file_properties.PropertyGroup(
self.template_id, [date_property, park_property, attraction_property, f_type_property, uid_property])
try:
self.dbx_api.file_properties_properties_add(p_target_file, property_group)
except dropbox.exceptions.ApiError as err:
sys.exit("ERROR: Add properties fail for " + p_target_file + " -- Property group alredy exist" + err)In this case I get the error above, and if I try what I explain you the last day:
property_data = dropbox.file_properties.PropertyGroup(self.template_id, [date_property])
property_park = dropbox.file_properties.PropertyGroup(self.template_id, [park_property])
property_attrac = dropbox.file_properties.PropertyGroup(self.template_id, [attraction_property])
property_type = dropbox.file_properties.PropertyGroup(self.template_id, [f_type_property])
property_uid = dropbox.file_properties.PropertyGroup(self.template_id, [uid_property])
peropety_gr_list = [property_data, property_park, property_attrac, property_type, property_uid]
try:
self.dbx_api.file_properties_properties_add(p_target_file, peropety_gr_list)
except dropbox.exceptions.ApiError as err:
sys.exit("ERROR: Add properties fail for " + p_target_file + " -- Property group alredy exist" + err)I got the 500 error. Also, I'd like to say that I already delete every Template in the user to work only with one first of all, but still in the same situation.
Greg-DB
Dropbox Community Moderator
6 years agoThanks! It looks like there's just a small issue in that code. The file_properties_properties_add method expects a list of 'PropertyGroup', so instead of:
dbx_api.file_properties_properties_add(p_target_file, property_group)
you should do:
dbx_api.file_properties_properties_add(p_target_file, [property_group])
- ADoncel6 years agoExplorer | Level 4
That was the thing I was missing.
Thank you very much.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
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, Facebook or Instagram.
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!