Updating issue priority in python is returning: Field 'Priority' cannot be set. It is not on the app

Humale Khan May 11, 2018

I'm trying to write a basic script that finds issues that are past due, and updates the Priority to 'Blocking'. I've made sure that I have edit permission, and the field is present in the edit issue screen. Here is the script:

 

# This script automatically updates an epic's 'initiative' field to the epic name

from collections import Counter
from jira import JIRA

jira = JIRA(server = 'https://examplesite.atlassian.net', basic_auth=('username', 'password')) # a username/password tuple

# Find all issues that are not done where the due date is past due
issues = jira.search_issues('project = "AS" AND issuetype = Task AND status not in (Done, "In production", "Wireframe complete", "Will not do") AND duedate < now()')

# For each issue, comment that it is past due
# Currently can't figure out why I can't update the Priority automatically
for issue in issues:
print('{}: {}'.format(issue.key, issue.fields.summary))
jira.add_comment(issue, 'This issue is past due.')
# issue.update(Priority='Blocking')

 

AS-91: test-1

Traceback (most recent call last):

  File "blocking.py", line 21, in <module>

    issue.update(Priority='Blocking')

  File "/Users/humale/Library/Python/2.7/lib/python/site-packages/jira/resources.py", line 483, in update

    super(Issue, self).update(async=async, jira=jira, notify=notify, fields=data)

  File "/Users/humale/Library/Python/2.7/lib/python/site-packages/jira/resources.py", line 232, in update

    self.self + querystring, data=data)

  File "/Users/humale/Library/Python/2.7/lib/python/site-packages/jira/resilientsession.py", line 157, in put

    return self.__verb('PUT', url, **kwargs)

  File "/Users/humale/Library/Python/2.7/lib/python/site-packages/jira/resilientsession.py", line 147, in __verb

    raise_on_error(response, verb=verb, **kwargs)

  File "/Users/humale/Library/Python/2.7/lib/python/site-packages/jira/resilientsession.py", line 57, in raise_on_error

    r.status_code, error, r.url, request=request, response=r, **kwargs)

jira.exceptions.JIRAError: JiraError HTTP 400 url: https://chwatlas.atlassian.net/rest/api/2/issue/10095

text: Field 'Priority' cannot be set. It is not on the appropriate screen, or unknown.

 

response headers = {'X-AUSERNAME': 'admin', 'X-AREQUESTID': '584984da-0e34-4e0a-add7-0e398d1f51b7', 'X-XSS-Protection': '1; mode=block', 'X-Content-Type-Options': 'nosniff', 'X-Seraph-LoginReason': 'OK', 'Strict-Transport-Security': 'max-age=315360000; includeSubDomains; preload', 'Content-Length': '125', 'Server': 'Atlassian Proxy/0.1.241', 'Connection': 'close', 'Cache-Control': 'no-cache, no-store, no-transform', 'Date': 'Fri, 11 May 2018 17:00:16 GMT', 'Content-Type': 'application/json;charset=UTF-8'}

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

2 answers

3 votes
Cyril_Bitterich February 17, 2020

This question is quite old but before other people are wasting time on this:

 

text: Field 'Priority' cannot be set. It is not on the appropriate screen, or unknown.

First of all "Priority" does not exist per default. You should use lowercase "priority".

Second: If it did exist the problem could be that the edit screen just does not allow the user to edit this field.

And lastly to edit the field shown as "Priority" using the python module "jira" you'd have to use:


issue.update(priority = {"name": "Blocking"})
Giuseppe_Passino February 19, 2020

This is the right answer, thanks.

0 votes
Humale Khan May 11, 2018

Just to be clear, the update issue line isn't actually commented out when I run it

Suggest an answer

Log in or Sign up to answer