Forums

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

unable to add label JIRA REST API when creating issue-SOLVED

Deleted user June 7, 2018

Trying to create issue with label, issue is created but label field is empty

 

in JSON file i have

 

"labels": [ "MANAGED_SERVICES" ],

 

headers = {"Content-Type": "application/json"}
data = {"fields":{"project":{"key":"CP"},"summary":"OC SPLA usage report for {current_month} {currentYear}".format(**locals()),"description":"Review OC SPLA usage report","issuetype":{"name":"Managed Service"},"customfield_10107":{"id":"10505"},"customfield_10006":"CP-3289"},"creator":{"displayname":"some user"},"labels": ["MANAGED_SERVICES"]}

 

 

1.png

 

4 answers

1 accepted

0 votes
Answer accepted
Deleted user June 7, 2018

finally found answer:

had to reorder fields

 

headers = {"Content-Type": "application/json"}
data = {"fields":{"labels":["MANAGED_SERVICES"],"reporter":{"name":"user"},"assignee":{"name":"emergencyadmin"},"project":{"key":"CP"},"summary":"OC SPLA usage report for {previous_month} {currentYear},"description":"some descr","issuetype":{"name":"Managed Service"},"customfield_10107":{"id":"10505"},"customfield_10006":"CP-3289"}}}

1 vote
Rambabu Patina _Appfire_
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.
June 7, 2018

Could you verify that you've got "labels" on the screens for project CP and issue type "Managed Service"?

Deleted user June 7, 2018

thanks for reply, i posted a picture-managed_service is visible from drop-down menu

Rambabu Patina _Appfire_
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.
June 7, 2018

Hi @[deleted], Can you include the 'creator' and 'labels' attributes with in the project scope in the JSON file. Like below.

{"fields":{"project":{"key":"CP"},"summary":"OC SPLA usage report for {current_month} {currentYear}".format(**locals()),"description":"Review OC SPLA usage report","issuetype":{"name":"Managed Service"},"customfield_10107":{"id":"10505"},"customfield_10006":"CP-3289","creator":{"displayname":"some user"},"labels": ["MANAGED_SERVICES"]}}
Deleted user June 7, 2018

  "creator": { "active": true, "avatarUrls": { "16x16": "https://secure.gravatar.com/avatar/5d92f3ce51d4a090cdcb9b77ee890989?d=mm&s=16", "24x24": "https://secure.gravatar.com/avatar/5d92f3ce51d4a090cdcb9b77ee890989?d=mm&s=24", "32x32": "https://secure.gravatar.com/avatar/5d92f3ce51d4a090cdcb9b77ee890989?d=mm&s=32", "48x48": "https://secure.gravatar.com/avatar/5d92f3ce51d4a090cdcb9b77ee890989?d=mm&s=48" }, "displayName": "some user", "emailAddress": "someuser@company.com", "key": "someuser", "name": "someuser", "self": "https://jira.corp.company.com/rest/api/2/user?username=someuser", "timeZone": "Europe/Belgrade" },

 

"labels": [ "MANAGED_SERVICES" ], "lastViewed": "2018-06-07T10:09:11.206+0000",

 

sorry for bad formatting

0 votes
Deleted user June 7, 2018

1.png

0 votes
Aleksandr Zuevich
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.
June 7, 2018

Hi Dragan,

is it your exactly sent json?
{"fields":{"project":{"key":"CP"},"summary":"OC SPLA usage report for {current_month} {currentYear}".format(**locals()),"description":"Review OC SPLA usage report","issuetype":{"name":"Managed Service"},"customfield_10107":{"id":"10505"},"customfield_10006":"CP-3289"},"creator":{"displayname":"some user"},"labels": ["MANAGED_SERVICES"]}

It has something strange like .format(**locals()).

Deleted user June 7, 2018

Hi Aleksandr,

current_month = datetime.now().strftime('%B')
currentYear = datetime.now().year

subject contains current month and year, that's why i put .format(**locals()), it's python interpolation syntax

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events