Create issue via API with labels

Warren
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.
November 6, 2017

I am trying to use the REST API to create an issue in Jira, which is something that I've had working successfully for ages, but the difference is I'm trying to put in labels as well.

The JSON below (without labels) to create an issue works perfectly :

{{
"fields": {
"project": {
"key": "DS"
},
"summary": "Updating of scripts from Sprint",
"description": "",
"issuetype": {
"name": "Task"
},
"customfield_12702": "3d",
"timetracking": {
"originalEstimate": "3d"
}
}
}}

 

but the same JSON with a few added lines for labels :

{{
"fields": {
"project": {
"key": "DS"
},
"summary": "Updating of scripts from Sprint",
"description": "",
"issuetype": {
"name": "Task"
},
"customfield_12702": "3d",
"timetracking": {
"originalEstimate": "3d"
},
"labels": [
"Testing",
"Automation"
]
}
}}

gives me an error 400 : Bad request.

Has anyone successfully created an issue with labels? What am I doing wrong?

1 answer

1 accepted

2 votes
Answer accepted
Kian Stack Mumo Systems
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 6, 2017

Your labels syntax. Could you verify that you've got "labels" on the screens for project DS and issue type Task? 

Warren
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.
November 6, 2017

Hi Kian

If I open a Task the labels field is on the main page, similar to Task Type, Priority, Status etc.

It ISN'T on the Create screens - is this the issue?

Thanks for your response

Warren
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.
November 6, 2017

Thanks Kian

I added the labels field to a create screen and it works now

Veeravel January 11, 2018

Hi Warren,

I am also facing same problem now and could you please help me how did you resolve for yourcase?

Warren
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.
January 11, 2018

As I stated above. The labels field needed to be on the Create screen

Amit April 2, 2019

Hi, 

I am new to JIRA API. Could you please post your code so that I understand where exactly to insert the labels code? Where is Create screen option?

Warren
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.
April 2, 2019

Hi @Amit 

A sample JSON file is posted at the top of this page which shows what is required to create an issue with labels included.

For the cloud based Jira, go to Project settings, then choose Screens and click on the "Screen" link for Create issue. Then ensure that labels shows, or add if not.

Amit April 2, 2019

Thanks Warren, 

Got it! 

Luc Bloom November 21, 2022

@Warren

Can I please see a copy of that example?

Suggest an answer

Log in or Sign up to answer