Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Python API: Create issue - 'Assignee' field is not populated

Dror Paz April 28, 2022

Hi

 

I am trying to create an issue in JIRA using Python code.

All is working fine (issue is created) except the assignee field is not being populated.

I am not getting any error when running it.

 

I assume I am doing something wrong but no idea what.

Any help is appreciated

 

assignee = 'Dror Paz'
jira_task = jira.create_issue(fields=ticket)

 

ticket = {
'project': {'key': project_key},
'summary': summary,
'description': description,
'customfield_11277': recommendations,
'issuetype': {'name': issue_type},
'components': components,
'priority': {'name': priority},
'assignee': {'assignee': assignee},
'customfield_10702': qualys_key,
}

 

 

 

3 answers

0 votes
Craig Anderson
Contributor
February 17, 2023

I tried:

'assignee': {'name': assignee},

Where assignee was either a name or a user id.  Both did not work.

What did work is:

"assignee": {"id": [atlassian user id]},

 I got this from the REST API documentation.

0 votes
Andrea Pannitti
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 28, 2022

Hi @Dror Paz ,

you should change the row:

'assignee': {'assignee': assignee},

with this:

'assignee': {'name': assignee},

and set assignee with your username.
 

Dror Paz April 30, 2022

Hi Andrea.

Thanks for that.

I did fix that and still seeing the same results.

The assignee is NOT updated.

 

One more thing. - When I remove the assignee from the ticket dictionary, the tickets are created with myself as the assignee

Andrea Pannitti
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 2, 2022

Hi @Dror Paz ,

it's strange because I tested my code and it worked.

However, to find the assignee id, you could call the rest api:

/rest/api/2/user?username=your_assignee_username

From response, look the key; it should be somethink like: JIRA... The number is your assigneeID.

Craig Anderson
Contributor
February 17, 2023

I tried:

https://[org api]/wiki/rest/api/rest/api/2/user?username=Craig%20Anderson'

But got a 404 error.

0 votes
Garrett McCreery
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 28, 2022

I have ran into this before, I believe the assignee needs to be the assignee id, not the assignee name.

Dror Paz April 30, 2022

Thx Garret.

Any idea how I can get the ID and how to set it?

Like 손윤호 likes this
Craig Anderson
Contributor
February 17, 2023

Use the Confluence REST API:

[base url]/user/bulk/migration?username=Craig&username=Anderson

Suggest an answer

Log in or Sign up to answer