set options for a multi-select custom field via script

HanQiao July 7, 2024

Hi Team

Im trying to add options to a multi-select custome field via Python script:


def set_field_options(field_id, options):

    url = f'{JIRA_URL}/rest/api/2/field/{field_id}/option'

    for option in options:

        data = { 'value': option }

        response = requests.post(url, data=json.dumps(data), auth=HTTPBasicAuth(USERNAME, API_TOKEN), headers=headers)

 

 

I always got an error like:

Failed to create option 'REPLACE LMD' for field 'customfield_10169'. Status code: 400, Response: {"errorMessages":[],"errors":{"fieldKey":"Field key 'customfield_10169' is not valid"}}

or

Failed to create options for field 'customfield_10169'. Status code: 400, Response: {"errorMessages":["Invalid request payload. Refer to the REST API documentation and try again."]}

Could you help me to solve the problem or give me a API documentation for reference?

Thanks a lot

1 answer

1 accepted

2 votes
Answer accepted
Joseph Chung Yin
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 7, 2024
HanQiao July 8, 2024

@Joseph Chung Yin 
Thanks a lot.
This reference is helpful.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events