Problem trying to add label using cURL

I'm attempting to add a release label to an issue via cURL.

My JSON - a one-liner - reads like (it's stored in a file called SetLabel.json)

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

My cURL command line reads like

'-X PUT --data @SetLabel.json https://mycompany.jira.com/rest/api/latest/issue/issuenumber'

and I'm getting an error that says

{"errorMessages":[],"errors":{"labels":"Field 'labels' cannot be set. It is not on the appropriate screen, or unknown."}}

My _curlrc file reads

-H "Content-Type: application/json"

-k

-u userid:password (to protect the innocent)

--silent

--show-error

and it looks like I'm matching the JSON shown in

https://developer.atlassian.com/display/JIRADEV/Updating+an+Issue+via+the+JIRA+REST+APIs

Any ideas?

2 answers

1 accepted

Are you allowed to edit labels from the UI issue screen? If not, then you can't update via API either. You may want to add the labels field to show on the issue screen.

If I go to More Actions / Labels, I can add/edit labels without issue. The field is showing on the screen - but not directly editable from that screen. I thought it might be security related, but that doesn't seem to be the case - I can change the labels at will.

***

Ah, but you might mean "Do you need to go to some type of other screen to edit it?" in which case, the answer is yes.

Changed JIRA configuration for the screens in question, adding that field explicitly; it can now be edited directly from the issue view/change screen...

And the script now works. Voile'!

Thanks, Bob!

I've been banging my head against the wall because of the deaded:

"Field 'labels' cannot be set. It is not on the appropriate screen, or unknown".

despite the fact that labels were there and I could edit them for within Jira.

And then I realized I was using Admin credentials for my cURL call... And the JIRA Admin, in my case, does NOT have "Edit Issue" privileges... Allowing Administrators to edit issues solved it for me. Hoping this helps!

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Jira

5 ways you can make the most of Jira Software and Bitbucket Cloud

As part of the Bitbucket product team I'm always interested in better understanding what kind of impact the use of our tools have on the way you work. In a recent study we conducted of software devel...

84 views 0 5
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you