It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Insert value into customfield of type "multi checkbox" using jira-python API

I am using jira-python API v0.13. (Snippets below exclude jira client set-up scaffolding for brevity.)

I need to update a multi-checkbox field which has NO VALUE currently, to make one of the boxes "checked".

Multi-checkbox field name = Flags

Values = Customer, Partner, Other

I've initalized the connection with JIRA successfully. I can get data from this multi-checkbox field for a record that HAS values for this multi-checkbox:

>>> i = jira.issue('ABC-123')
>>> f = i.fields.customfield_10060
>>> [v.value for v in reversed(f)]

However, when I am unable to update the field to insert a new value. Specifically, I am attempting to push values into a record that has NO VALUES set for the checkbox yet (don't know if that's the problem or not, since I can't insert values for one that has one or more values, either!)

This doesn't work:

>>> i = jira.issue('ABC-155')
>>> i.update(fields={'customfield_10060': {'value': 'Customer'}})
error is jira.exceptions.JIRAError: HTTP 400: "{u'Flags': u'data was not an array'}"

Neither does this:

>>> i = jira.issue('ABC-155')
>>> i.update(fields={'customfield_10060': ['value', 'Customer']})
error is jira.exceptions.JIRAError: HTTP 400: "{u'Flags': u'expected Object'}"

Comments / suggestions appreciated.

1 answer

1 accepted

2 votes
Answer accepted

You should pass array of objects as specified here -

i.update(fields={'customfield_10060': [{'value': 'Customer'}]})


Thanks so much, Boris. That link to the dev wiki is very helpful indeed!

@Boris Georgiev [Botron]

The problem with this approach is that the update will overwrite previous values.

Assuming we have a multiple select checkbox custom_field:

[ ] option1 
[ ] option2
[x] option3

after update 

i.update(fields={'customfield_10060': [{'value': 'option1'}]})

field will be

[x] option1 
[ ] option2
[ ] option3


The option 3 is gone.
Do you know how can we adapt the update method to just "add" (select) another option, without erasing the previously selected options ??? result in this case should be 

[x] option1 
[ ] option2
[x] option3

Try getting the value of the field first, then make your updates and last - pass the value back to JIRA for update

@Boris Georgiev [Botron], I am almost there...

for issue in issues:
	print "hi all, i am here"
	selected_values = issue.fields.customfield_13336
	values = "["
	for value in selected_values:
		values += "{{'value': '{0}'}},".format(value)
	values = values[:-1]
	values += "]"
	#issue.update(fields={'customfield_13336':[{'value':hostOption} ,{'value':targetOption}]})

The error:

response text = {"errorMessages":[],"errors":{"Target Environment":"data was not an array"}}


I basically get all values and store in a string, then I try to provide over issue.update(xxx).

Do you have an idea how I can compose a variable array of objects with the values to be provided to issue.update?

@Gabriel Almeida2

This should work, applying to your example here :

 selected_values = issue.fields.customfield_13336
 values = []
for value in selected_values: values += [{'value':str(value)}] issue.update(fields={'customfield_13336':values})

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira

We want to hear from you! How do you use Slack and Atlassian together?

Hi Everyone! My name is Mina and I am on Atlassian’s Ecosystems Marketing team. Our team is focused on our technology partnerships and marketplace apps. One of Atlassian’s partners is Slack, who ...

22 views 0 2
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you