2

I'm trying to update an existing JIRA using the jira-python module (http://jira-python.readthedocs.org/en/latest/). Specifically I'm trying to set the fixesVersion list of an issue. I've been trying for a while with no luck. What am I missing?

issue = jira.issue('DUC-391')
issue_dict = { 'fixVersions' : [{'id': '10115'}] }
issue.update(fields=issue_dict)

Returned stackTrace:

Traceback (most recent call last):
  File "post-commit-jira.py", line 35, in <module>
    issue.update(fields=issue_dict)
  File "/Library/Python/2.6/site-packages/jira/resources.py", line 193, in update
    super(Issue, self).update(**data)
  File "/Library/Python/2.6/site-packages/jira/resources.py", line 72, in update
    raise_on_error(r)
  File "/Library/Python/2.6/site-packages/jira/exceptions.py", line 29, in raise_on_error
    error = errorMessages[0]
sorin
  • 161,544
  • 178
  • 535
  • 806
smm100
  • 113
  • 1
  • 2
  • 8

2 Answers2

3

Take a look at the example of add, set and remove for components in https://developer.atlassian.com/display/JIRADEV/JIRA+REST+API+Example+-+Edit+issues You can use the name instead of the id which is helpful, e.g.

issue_dict = { 'fixVersions' : [{'add': {'name': 'Name of the version 10115'}}] }
juanchopanza
  • 223,364
  • 34
  • 402
  • 480
mdoar
  • 6,758
  • 1
  • 21
  • 20
  • 2
    Thanks for the link - needed to tweak the json above a little but put me on the right path. Correction was: {"fixVersions" : [{"add" : [{"name" : "version-name"}]}]}} – smm100 Jan 25 '13 at 02:03
  • Glad it worked. Bit surprised really since Ben Speakmon (jira-python) author thought verbs like "add" weren't supported yet in the issue at https://bitbucket.org/bspeakmon/jira-python/issue/10/verbs-not-working-with-update-function – mdoar Jan 25 '13 at 18:40
  • Whoops - sorry I wasn't clear. I meant to say my code was valid for the jira-python plugin, but the problem was that the JIRA issue had some required fields unset. The only way I could debug this was by using curl and following the instructions given in the link you posted. – smm100 Jan 29 '13 at 01:37
  • how to do the opposite, means get the name of the field fixversion ? – MokiNex Jan 15 '19 at 11:41
  • https://docs.atlassian.com/software/jira/docs/api/REST/7.6.1/#api/2/version-getVersion – mdoar Jan 16 '19 at 20:24
1

Played around more with it, realized the error.

It was failing due to some required fields being unset. Code snipped in the original question is ok, error reporting from the jira-python library however leaves a lot to be desired...

smm100
  • 113
  • 1
  • 2
  • 8