Daniel Strong
Daniel Strong

Reputation: 213

Jira Python Custom Fields

I am writing a script to create bugs. We have many custom fields and I cannot figure out how to get them to work correctly in the python code. Can someone please help explain? I have read through as many articles as I can find but none of the solutions are working.

One example of my custom field names is customfield_15400 and has a default value of "NO". The error I get with my below code is:

response text = {"errorMessages":[],"errors":{"customfield_15400":"Could not find valid 'id' or 'value' in the Parent Option object."}}

Code:

    project_dict = {'Aroid':'SA', 'OS':'SC'}
    epic_dict = {'Aroid':'SA-108', 'OS':'SC-3333'}

    for index, row in bugs.iterrows():
        issue = st_jira.create_issue(project= project_dict[row['OS']], \
                            summary= "[UO] QA Issue with '%s' on '%s'" % (row['Event Action'], row['Screen Name']), \
                            issuetype= {'name':'Bug'},\
                            customfield_15400="No"
                            )

Upvotes: 3

Views: 6693

Answers (4)

issue.update(fields={'customfield_10100': {'value','Two'}})

above will throw the error saying data was not an array

"response text = {"errorMessages":[],"errors":{"Custom_field":"data was not an array"}}"

=> you could try like this -:

issue.update(fields={'customfield_10100': [{'value': "Two"}]})

Upvotes: 2

Daniel Strong
Daniel Strong

Reputation: 213

Incase anyone else needs the solution. Below works.

project_dict = {'Android':'SA', 'iOS':'SIC'}
epic_dict = {'Android':'SA-18', 'iOS':'SIC-19'}

for index, row in bugs.iterrows():
issue = st_jira.create_issue(
                            summary= "[UO] QA Issue with '%s' on '%s'" % (row['Event Action'], row['Screen Name']),\
                            labels = ['UO'],\
                            assignee={"name":""},\
                            versions=[{"name":"4.4"}],\
                            fields={'project' : project_dict[row['OS']], \
                                    'summary': "[UO] QA Issue with '%s' on '%s'" % (row['Event Action'], row['Screen Name']),\
                                    'labels': ['UO'],\
                                    'assignee':{"name":""},\
                                    'versions':[{"name":"4.4"}],\
                                    'issuetype': {'name':'Bug'},\
                                    'customfield_15400': {'value':'Yes'}} 

                            )

Upvotes: 3

Amar Khot
Amar Khot

Reputation: 1

issue.update(fields={'customfield_10100': {'value','Two'}})

I have a multiselect list and below error occurs if i try to update

"response text = {"errorMessages":[],"errors":{"Custom_field":"data was not an array"}}"

Upvotes: 0

ojathelonius
ojathelonius

Reputation: 804

Try the following :

customfield_15400={ 'value' : 'NO' }

You can also do the following, value_id being the id of the value in your Select Field :

customfield_15400={ 'id' : 'value_id' }

Indeed the value of a SelectField is an object, described by its value and its ID.

Upvotes: 5

Related Questions