Home > Software design >  Python script to update single select custom field in jira
Python script to update single select custom field in jira

Time:09-20

I am trying to update a single select custom field (customfield_11104). This field have 5 option 1. None 2. PR Review 3. Production 4. Staging 5. Rejected. I want to update this field to staging using a python script. Below script showing some error. response text = {"errorMessages":[],"errors":{"customfield_11104":"Could not find valid 'id' or 'value' in the Parent Option object."}} Could you please help to update this custom field to staging using python script.

from jira import JIRA
import urllib3
import sys
urllib3.disable_warnings()
API_token = 'xxx'
jiraOptions = {'server': 'https://xxx','verify': False}
authedJira = JIRA(jiraOptions, token_auth=API_token,max_retries=0)
#example
ticket = sys.argv[1]
issue = authedJira.issue(ticket)
issue.update(fields={'customfield_11104': [{'value':'Staging'}]})

CodePudding user response:

Based on the doc examples and your description of your custom field. It seems you are unnecessarily enclosing your dictionary in a list.

It should probably be:

issue.update(fields={'customfield_11104': {'value':'Staging'}})

Or, as the error message suggests:

issue.update(fields={'customfield_11104': {'id':4}})
  • Related