0

I am trying to set the labels field for a JIRA ticket in Python using the jira-python API.

With a valid JIRA issue object, created with issue = jira.issue(jira_ticket), I have tried the following:

  • issue.update(labels='AAA'): gives a not on the appropriate screen error as below.
  • issue.update(fields={'labels':'AAA'}): also gives a not on the appropriate screen error as below.

  • issue.fields.labels.append(u'AAA'): does not produce an error, but does not update field. I guess it updates the issue object, but doesn't push back to JIRA server.

I seem to always receive the error:

jira.exceptions.JIRAError: JiraError HTTP 400 url: https://someserver/rest/api/2/issue/nnnnnn
text: Field 'labels' cannot be set. It is not on the appropriate screen, or unknown.

This is the same error as this post, Python - JIRA - Modify Labels, but for different reasons - namely, labels are not turned off here, and I can set them with the web interface: See Image: JIRA Labels Added in Web UI and Image: updated JIRA issue with Labels.

If I dump out the raw fields for the issue in question, having added labels to it using the Web UI as above, then I can see the labels in the Python JIRA Issue object:

Field: 'labels', Value: ['StackOverflow', 'TAGTHATICANSEARCHFOR']

If anyone can point me in the right direction, it would be greatly appreciated.

M1GEO
  • 223
  • 4
  • 11

4 Answers4

1

I tried it in many ways and the one that worked was passing the labels as an array:

in this way:

issue.update(fields={"labels":['AAA']})
bummi
  • 27,123
  • 14
  • 62
  • 101
1

If you just want to add a label, you can follow this example:

# Or modify the List of existing labels. The new label is unicode with no
# spaces
issue.fields.labels.append("new_text")
issue.update(fields={"labels": issue.fields.labels})
jtpereyda
  • 6,987
  • 10
  • 51
  • 80
0

Judged from the error message, the "labels" field is not on the edit screen of your target issue.

Refer to the JIRA documentation to get a deeper understanding of screens in JIRA: https://confluence.atlassian.com/adminjiraserver071/defining-a-screen-802592587.html

wtfzn
  • 533
  • 5
  • 13
  • Yes, so it would seem; However, given that I can actually edit it on the target issue using the WebUI that would suggest it should be doable? I also have sufficient permissions. – M1GEO Jul 14 '17 at 12:47
0

After much digging around for an answer, it seems there is an ongoing problem with this.

It appears that I need to access labels manager to check issue labels and modify labels: https://community.atlassian.com/t5/Answers-Developer-Questions/How-to-add-a-Label-with-Java-Rest-API/qaq-p/560837

There's an issue posted with Atlassian - vote it up: https://ecosystem.atlassian.net/browse/JRJC-109

Hopefully this helps someone if they find this post.

M1GEO
  • 223
  • 4
  • 11