Forums

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

Insert value into customfield of "select list" type using jira-Python API

Rodrigo Bammann February 5, 2021 edited

I've been using Jira-Python REST API version 0.1.dev50 to create an app that will update custom fields in a Jira issue (Snippets below exclude Jira client set-up scaffolding for brevity).

I need to update a custom field of "select list" type in relation to the user's option. The options are the same as in the Jira's list.

Updating multiple line text is possible without any problem.

However, I can't update the "select list" type, receiving the following:

JiraError HTTP 400 url: https://your.place.net/rest/api/2/issue/26416
text: Could not find valid 'id' or 'value' in the Parent Option object.

The following code works well if I am using a custom field of text (multiline) type:

customfield = textbox.objectName()
customtext = textbox.currentText()

self.Jissue.update()
self.Jissue.update(fields = {customfield: customtext})

The textbox.objectName() will retrieve the custom field id.

From what I got from the Jira-Python's documentation, the problem is how to set up the issue.update part. However, I can't find the right way to update this "select list" type of custom field.

Comments on this, or suggestions, will be greatly appreciated.

1 answer

1 accepted

1 vote
Answer accepted
Edwin Kyalangalilwa
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.
February 5, 2021

Hi @Rodrigo Bammann ,

Here's some examples in the JIRA REST API: Setting custom field data for other field types 

Also, recently .... none of these worked for me and i simply had to use:

'customfield_14215': [test]

I got to this by looking at the JSON representation of an issue that had a value for the field i was looking to update

<jira-url>/rest/api/3/issue/{issueIdOrKey}
Rodrigo Bammann February 10, 2021

Based on the JIRA REST API that you provided, @Edwin Kyalangalilwa , I was able to change it and it worked.

The following modification is what made it work:

self.Jissue.update()
self.Jissue.update(fields = {customfield: {"value": customtext}})

Thanks for the help!

Like Edwin Kyalangalilwa likes this
Edwin Kyalangalilwa
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.
February 12, 2021

Glad to hear it's working!

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
atlassian, atlassian government cloud, fedramp, webinar, register for webinar, atlassian cloud webinar, fedramp moderate offering, work faster with cloud

Unlocking the future with Atlassian Government Cloud ☁️

Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.

Register Now
AUG Leaders

Atlassian Community Events