The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

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

How can you update label type in Servicedesk using REST API?

TooManyFormChecks
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 5, 2021

I am having trouble adding a component to a label type in Jira.

import browser_cookie3
import requests
import json

cj = browser_cookie3.load()
url = ""

text = {'fields': {'customfield_xxxx':['test']}}

r = requests.put(url, json=text, cookies=cj)

print(r.status_code)

With the above code, I can update the label list. However, I need to achieve the following - The label contains[ ABC, 123 ] and I want to add component [ZXC] to the existing list. My goal is to have[ABC, 123, ZXC] but with the above shown code it updates to - [ZXC]

I did find that in editmeta there is "add" function for the customfield, however, I was unable to make it work.

Thank you in advance!

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
Answer accepted
Dirk Ronsmans
Community Champion
January 5, 2021

Hi @TooManyFormChecks ,

The JSON you need to use is as follows:

{
"update": {
"labels": [{
"add": "test_2"
}]
}
}

This will add the label "test_2" but not overwrite the whole field. 

TooManyFormChecks
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 5, 2021

Thank you so much! I was so close as well! I had fields but I needed to place update! Also, it could be that I tried this and was not working because I was using /rest/api/2/issue/ISSUEKEY/editmeta but I did not need to append it with editmeta. Once again, thank you very much !