Forums

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

Using python, how can I add a new value to a single choice list?

Joseph Fota January 29, 2024

Is there a way to add a value to a single choice list using python?  I'm looking for a simple python script using either the Jira module or the api.   I have the custom field ID and the context ID, but I'm not finding how to add the custom field option.   I tried the following api update example script from the , but the script throws an error.

url = "https://bogus.atlassian.net/rest/api/3/field/customfield_1111/context/00000/option"

auth = HTTPBasicAuth(username, token)


headers = {
  "Accept": "application/json",
  "Content-Type": "application/json"
}

payload = json.dumps( {
   "options": [
    {
      "disabled": false,
      "value": "RHEL 8.9" 
    }
  ]   
} )

response = requests.request(
   "POST",
   url,
   data=payload,
   headers=headers,
   auth=auth
)

print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")))

 

Response:

Traceback (most recent call last):
  File "./updateChoices.py", line 41, in <module>
    "disabled": false,
NameError: name 'false' is not defined

 

1 answer

0 votes
Joseph Fota January 29, 2024

Apparently, the example is wrong.  Create custom field options (context)  The false should be False.  

Suggest an answer

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

Atlassian Community Events