Update custom field via Python API

I’m using the python API to update a custom field.

I got this dictionary from the enum_options for this field:

new_enum_value_dict = {'color': 'cool-gray',
     'enabled': True,
     'gid': 'XXXXX',
     'name': 'NewValueName',
     'resource_type': 'enum_option'}

Here I try to update a custom field with the new value:
client.custom_fields.update_custom_field(customFieldGid,{'enum_value':new_enum_value_dict})

I receive what looks like a successful response (no error messages) but the field is not updated. Do I have an error with my syntax?

Thank you,
Brian

Hi,

I am wondering if you are not confusing updating the value of a custom field on a task, and updating the actual custom fields. To update an enum value it looks like there is an endpoint for it did you try?

If you look at the doc to update the entire field, there is no “enum_value” attribute.

3 Likes

Ok, looks like I was confusing the two. So thank you!

As a follow up, to update the value of a custom field on a task, is this the correct syntax?
client.tasks.update(taskGid,{custFieldGid:‘value’})

Where ‘value’ needs to be a dictionary of the form:

{
  "data": {
    gidForSpecifcCustomField:enum_valueDictWithUpdatedValues
}
}

Note: I tried this and am getting normal response back but again with no update to the value.

I think my main issue is that I’m having trouble understanding the format of the {‘field’:‘value’} parameter in the documentation here.

Thanks again for your help.

I believe this is more along the lines of client.tasks.update(taskGid,{custom_fields:{custFieldGid:‘value’}})

1 Like

Yesss this worked. Thank you Bastien! For posterity: ‘value’ should be the Gid of the enum_option for a single select custom field. Thanks again.

1 Like

Also custom_fields should be in quotes: “custom_fields”

1 Like