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

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 !

Suggest an answer

Log in or Sign up to answer