I'm trying to update a custom field that is basically a version field using jira-python.
I have no trouble getting the set of versions for the project, finding the right version to set to, but where I'm stuck on is actually updating this custom version field.
Here are some relevant code:
pl = jira.project('PL')
versions = jira.project_versions(pl)
# assume the function below returns list of issues I want to update
issues = query_resolved_issues()
for i in issues:
# assume this function selects the right version in versions
update_version = get_right_version(i, versions)
i.update(customfield_10303=update_version)
Error occurs on the update line:
File "/usr/local/lib/python2.7/site-packages/jira/resources.py", line 352, in update
super(Issue, self).update(async=async, jira=jira, fields=data)
File "/usr/local/lib/python2.7/site-packages/jira/resources.py", line 148, in update
data = json.dumps(data)
File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 243, in dumps
return _default_encoder.encode(obj)
File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.py", line 207, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.py", line 270, in iterencode
return _iterencode(o, 0)
File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.py", line 184, in default
raise TypeError(repr(o) + " is not JSON serializable")
TypeError: <JIRA Version: name=u'IT79 - 6/11/15', id=u'12902'> is not JSON serializable
I made sure that the value stored in the custom field should be the version object itself (like if I set the release version manually on an issue on JIRA and get the value of the customfield_10303 in this case I return the same object type as what I'm trying to set the object to during update. Anyone have ideas?