Forums

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

Setting Fix Version/s via rest api using a dictionary in Python

Tom Garland June 21, 2024

Hi.

I'm trying to create a new jira story using a dictionary in python. Everything works except the setting of the Fix Version/s field. Here is the code:

------------

def create_gen_jira_story(jira_project,summary,description,issuetype,assignee,labels,fixby,fixversion):

# Creates a general jira story with a pre-defined set of values. Uses a dictionary to build the story

issue_dict = {

'project': {'key': str(jira_project)},

'summary': summary,

'description': description,

'issuetype': {'name': issuetype},

'assignee': {'name': assignee},

'labels': [labels],

'customfield_10002': str(fixby),

'fixVersions': fixversion

new_issue = jira_con.create_issue(fields=issue_dict)

----------------

when I run the python script I get the following error:

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

Question is - how can I set the "Fix Version/s" field?

 

If I remove the "fixVersions: fixversion" line the story is created correctly

 

Thanks

 

 

2 answers

1 vote
Jim Knepley - ReleaseTEAM
Atlassian Partner
June 21, 2024

The API documentation shows the "fixVersions" field expecting a list of dictionaries:

 "fixVersions": [ { "id": "10001" } ],

 

You will almost certainly need to look up the project ID based on the version name to know the ID value(s) that you want to use.

 

0 votes
Nicolas Grossi
Banned
June 21, 2024

You might try with an array of strings ? and add operation too ?

 

See the following example: https://community.atlassian.com/t5/Jira-questions/Error-data-was-not-an-array-when-updating-customfield-and/qaq-p/1321407

 

Nicolas

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Product Admin
TAGS
atlassian, jira cloud certification, managing jira projects, jira project administration, jira cloud exam, atlassian certification, agile project management, jira workflows, jira permissions, jira training, jira cloud skills, atlassian learning

Become a Certified Jira Service Project Expert 🦸🏻‍♂️

Validate your expertise in managing Jira Service Projects for Cloud. Master configuration, optimize workflows, and manage users seamlessly. Earn global 🗺️ recognition and advance your career as a trusted Jira Service management expert.

Get Certified! ✍️
AUG Leaders

Atlassian Community Events