Issues Updating Custom User Field Using Python

Kevin Porsolt December 21, 2020

I created a script in Python that reads an underlying database table and updates a custom user field (Team Lead) based on new organization changes. I am having issues actually updating the user type custom field. I know Atlassian made changes to the structure of user fields to now use the accountId, but that still did not seem to work. Any help is appreciated.

I authenticate using user name and security_token which is set as a variable I call auth_jira to use throughout my script.

Code provided below:

LOG.debug('Updating candidate Jira issue team leads...')
for ix, row in acct_lead_df.iterrows():
LOG.debug(f"{row['key']}|{row['issueType']}|{row['acctTeamLead']}")
auth_jira.issue(row['key']).update(fields={'customfield_10268': [{'accountId': row['id']}]})

 

2 answers

1 accepted

0 votes
Answer accepted
Prince Nyeche
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.
December 22, 2020

Hi @Kevin Porsolt 

Welcome to Community! I believe your payload might be wrong, when updating a user, you shouldn't wrap the value in a list. you should do:

{'customfield_10268': {'accountId': row['id']} } 

 Let us know how it goes.

Kevin Porsolt December 22, 2020

Hey @Prince Nyeche thank you for your response. This change seems to have it running correctly. Thank you!

0 votes
Ismael Jimoh
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.
December 21, 2020

Hi @Kevin Porsolt 

Please DO NOT do this as you risk corrupting your database. Most importantly, Atlassian and most wouldn’t be able to support you if things go wrong.

Rather parse your request via rest api and update the custom field accordingly.

You can find the official api here: https://developer.atlassian.com/cloud/ 

Click Rest API link for the correct product you use(I suspect you use server/dc since you mentioned a database).

Cheers.

Kevin Porsolt December 22, 2020

Hey @Ismael Jimoh thank you for the response. Sorry for not being clear here. I am using Jira Cloud not server. Our Jira data is exported to an Aurora Data lake that we leverage for several downstream processes. I will take a look at the documentation you provided.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events