Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

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 Leader Jan 05, 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. 

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
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you