Hello! I'm using the JIRA library to collect information about all tickets.
Here is my authorization:
jira = JIRA(options= {'server': 'https://xxx.xx'}, token_auth = 'yyy')
And here is my code.
issues = []
for i in range(0, total, 1):
try:
tikets = jira.search_issues(JQL, maxResults=1, startAt=i)
for keyid in range(len(tikets)):
key_name = str(tikets[keyid])
issue = jira.issue(key_name, expand='issuelinks,issuetype')
x = {}
x['ID'] = key_name
x['issue_created'] = issue.fields.created
x['project'] = issue.fields.project.name
issues.append(x)
except Exception as e:
print(key_name)
print(f"Ошибка: {e}")
continue
The code works well on almost all tickets. However, several receive an error 401 - unauthorized. At the same time, I can view these tickets in Jira and receive information through Postman. What could be the problem?
I believe this is one of those rare instances where a session might have been lost during transit when querying Jira issue via the API. I'm not sure what the cause is, but if, you receive this for a small fraction of the tickets. Probably what you can do is auth again within that loop using the same variable name you used to instantiate the auth login, probably that might help.
For example
# initial jira auth here
# ...
for i in some_loop:
# do some loops here
...
jira = JIRA(options= {'server': 'https://xxx.xx'}, token_auth = 'yyy')
# other code about other stuff here
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.