简体   繁体   中英

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

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']

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']

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM