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."}}