Forums

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

Creating Issue over REST API - setting Priority and Labels doesn´t work

Wilhelm October 28, 2021

Hi together,

 

I have a Problem with the Jira REST API. I´m trying to transfer Requirements from one Jira Instance to another. I´m using Power Scripts: SIL for this, but I guess its a general question/problem.

 

I´m trying to create Issues in the 2nd Jira Instance over REST API and with some fields it works fine. But I want to pass all fields like priority, labels and so on. 

My current JSON-String looks like this:

 string jsonString = "{"+
"\"fields\": {"+
"\"project\":"+
"{"+
"\"key\": \""+ projectKey_OfIssue +"\""+
"},"+
"\"summary\": \""+ summary_OfIssue +"\","+
"\"description\": \""+ description_OfIssue +"\","+
"\"issuetype\": {"+
"\"name\": \""+ issuetypeName_OfIssue +"\""+
"},"+
"\"reporter\": {"+
"\"name\": \""+ reporter_OfIssue +"\""+
"},"+
"\"priority\": {"+
"\"Id\": \""+ priority_OfIssue +"\""+
"},"+
"\"labels\": [ "+
labels_OfIssue+
" ],"+
"\"customfield_10205\": \""+ projectItemKey_OfIssue + "\""+
"}"+
"}";

 

Currently I´m trying it with hardcoded Strings for the variables. In the future it will get the Values automatically over Variable Resolution from SIL (summary and so on).

 

The String as an output looks like this:

{"fields": {"project":{"key": "TESTPROJ"},"summary": "New Issue created with Rest API","description": "Test Description","issuetype": {"name": "Work Package"},"reporter": {"name": "user"},"labels": [ "Hardware", "Software" ],"customfield_10205": "TESTPROJ-13"}}

The response of the server is this (its the same for priority):

400:{"errorMessages":[],"errors":{"labels":"Field 'labels' cannot be set. It is not on the appropriate screen, or unknown."}}:

I´ve already tried using "name" OR "id" as priority, nothing works, also I´ve tried different orders of fields, still not working.

 

I hope somebody can help with this.

 

Best regards,

Wilhelm

1 answer

1 accepted

0 votes
Answer accepted
Yanty Ghani [ServiceRocket]
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.
October 28, 2021

Hi Wilhelm,

That error message means that it cannot find the field in create issue screen. Can you please check that fields "Labels" and "Priority" are added to create issue screen of issue type "Work Package"?

Wilhelm October 28, 2021

Hi Yanty,

 

it is actually because of this. Thank you very much!

Yanty Ghani [ServiceRocket]
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.
October 28, 2021

I'm glad that your issue is resolved :)

Like Wilhelm likes this

Suggest an answer

Log in or Sign up to answer