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 to add a Label with Java Rest API?

name lastname Aug 18, 2013

There is not spezial Methode in the class IssueInputBuilder. But how to add a Label?

Thanks

5 answers

1 accepted

2 votes
Answer accepted
Shane McCarron Aug 19, 2013

Just managed to get it working!

issueBuilder.setFieldValue("labels",Arrays.asList("label1", "label2"));

3 votes

Hi,

You can use the 'editmeta' URL for doing that. It requires the same argumentas as the 'issue' URL. We have some examples of editing issues via REST:

- https://developer.atlassian.com/display/JIRADEV/JIRA+REST+API+Example+-+Edit+issues

Then, you can use a sniplet like this:

{
    "update": {
    "fields": {
        "labels": [
            "bugfix",
            "blitz_test"  ],
              }
        }
}

Best regards,
Lucas Timm

name lastname Aug 18, 2013

And how i use this with the Java Rest API?

That's my way to create a ticket.

final IssueInputBuilder issueInputBuilder = new IssueInputBuilder(ticket.getProject(), issueTypeID, summary)
			.setDescription(ticket.getDescription())
			.setAssigneeName(ticket.getAssignee())
			.setPriorityId(priorityID);
final BasicIssue basicCreatedIssue = issueClient.createIssue(issueInputBuilder.build(), pm);

1 vote
Rambanam Prasad Aug 18, 2013

check this issu, vote up to implement this feature

https://ecosystem.atlassian.net/browse/JRJC-109

0 votes
Shane McCarron Aug 19, 2013

Is there a way to achieve this using issueBuilder.setFieldValue? I have tried variations on

issueBuilder.setFieldValue("labels", labelArray);

where the labelArray parameter is a String array, an array list, or similar but so far have not succeeded...

0 votes
Thor Simon Dec 04, 2018

The suggestion to use "editmeta" is wrong (or, at least, has become wrong by late 2018).  A correct example using PUT to the issue endpoint can be found here. 

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Sourcetree

Sourcetree for Windows - CVE-2019-11582 - Remote Code Execution vulnerability

A vulnerability has been published today in regards to Sourcetree for Windows.  The goal of this article is to give you a summary of information we have gathered from Atlassian Community as a st...

359 views 0 9
Read article

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