Python JIRA Rest API get cases from board ORDER BY last updated

Question:

I have sucessfully managed to get a Jira rest API working with Python code. It lists cases. However, it lists the last 50 cases order by created date. I want to list the 50 cases order by updated date.

This is my Python code:

jiraOptions = {'server': "https://xxx.atlassian.net"}
jira = JIRA(options=jiraOptions, basic_auth=(jira_workspace_email, jira_api_token))

for singleIssue in jira.search_issues(jql_str=f"project = GEN"):
    key = singleIssue.key
    raw_fields_json = singleIssue.raw['fields']
    created = raw_fields_json['created']
    updated = raw_fields_json['updated']
Asked By: Europa

||

Answers:

You can search for issues using JQL string and do the ordering like this-

jiraOptions = {'server': "https://xxx.atlassian.net"}
jira = JIRA(options=jiraOptions, basic_auth=(jira_workspace_email, jira_api_token))

# Modify the JQL string to include the "order by" clause
jql_str = f"project = GEN order by updated"

for singleIssue in jira.search_issues(jql_str=jql_str):
    key = singleIssue.key
    raw_fields_json = singleIssue.raw['fields']
    created = raw_fields_json['created']
    updated = raw_fields_json['updated']
Answered By: Always Sunny
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.