Home > front end >  Python JIRA Rest API get cases from board ORDER BY last updated
Python JIRA Rest API get cases from board ORDER BY last updated

Time:01-01

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

CodePudding user response:

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