4
votes

Using JIRA version 4.2. With Python 2.7 and suds 0.4, how can I create an issue with assignee field set? The assignee field gets ignored in the code below.

new_issue = client.service.createIssue(auth, {
            'project': 'NAHLP',
            # issue_type = Incident Report.
            'type': '11',
            'assignee': 'assignee_username',
            'priority': '2',
            'summary': 'summary',
            'description': 'description',
            'customFieldValues': [
                # Reporter Location = NA.
                {'customfieldId':'customfield_10019', 'values':['10011']},
                ]
            })

I know that you can update the issue with an assignee (see my answer) but I want to assign the issue when creating it. Is this possible?

Note: All our usernames are the users' email addresses and contain '@' and '.' symbols.

3

3 Answers

4
votes

Thanks to Dave for this alternative of updating the issue with an assignee. Note, this does not answer the question of how to assign a ticket when creating an issue.

I need to be passing an array as the value of the assignee field even though it only allows one value. (The same applies to any field you want to update with the updateIssue call). So, instead of:

client.service.updateIssue(auth, 'NAHLP-38630', {'assignee': '[email protected]',})

do this:

client.service.updateIssue(auth,'NAHLP-38630',[ {'id' : 'assignee', 'values' : ['[email protected]']}])
1
votes

You should be able to create an issue and set the assignee. Make sure you're using the user name, not the full name or email address. Check the atlassian-jira.log for errors. Check the assignee is not hidden on the create screen for that issue type in that project. The JIRA Python CLI has a createissues action that should do exactly this with suds.

~Matt

1
votes

Thanks to Dave, again, for this answer.

The soap API won't set fields that aren't visible on the Jira UI's screen at the relevant point of the workflow. The "create issue" screen is considered the relevant screen when you call the createIssue method, but the assignee field isn't visible on the 'create issue' screen.

You could either do your createissue call without the assignee, then follow it with an updateissue call to set assignee. Alternatively, we could add the assignee field in the initial create issue workflow.