Jira api search issues can't get more than 20 results

Hi there,

Please tell me how to get more than 20 results using Jira server api.

In the code below, maxResults is specified as 1000, but the result is 20.

There are actually many more issues.

Specifying maxResults up to 20 works as expected, but if it’s 21 or higher, the result will be 20.

start_date = (datetime.today() - timedelta(days=10)).strftime('%Y-%m-%d')
end_date = (datetime.today() - timedelta(days=1)).strftime('%Y-%m-%d')

SEARCH_ENDPOINT = "https://jira.thingy.com/rest/api/2/search"

PROJECT_KEYS = ["MYPRO", "MYPRO2", "MYPRO3"]

projects_query = " OR ".join([f"project = {key}" for key in PROJECT_KEYS])
jql = f"({projects_query}) AND worklogDate >= {start_date} AND worklogDate <= {end_date}"
params = {
    "jql": jql,
    "fields": "worklog,key,summary",
    "maxResults": 1000
}
response = requests.get(SEARCH_ENDPOINT, headers=headers, params=params)

print(response)
print(f'maxResults: {response.json()["maxResults"]}')
print(f'total: {response.json()["total"]}')
print(f'issues: {len(response.json()["issues"])}')

result:
<Response [200]>
maxResults : 1000
total : 20
issues : 20

Thank you

Yosuke

Welcome to the Atlassian Developer Community, @y-nitobe!

By default, this REST API should return a maximum of 50. In your specific case, it seems like the maximum value is set to 20. To validate, kindly go to Jira’s advanced settings (link to instructions here) and verify the value for the jira.search.views.default.max key – the value here influences the maximum allowable value for maxResults.

Kindly try this out and let us know how it goes.

Ian

Thank you brother!

The company that manages Jira and my company are different companies, so I think it will take some time to verify what you taught me.
I’ll report back once I’ve verified it.

I have something to report.
I can get over than 20 results after I added “startAt: 0” to the parameter. This may also be the cause.

params = {
    "jql": jql,
    "fields": "worklog,key,summary",
    "maxResults": 1000, 
    "startAt":  0,
}

Thanks to you, I have time, so I’m going to skip work and go to the mountains with my dog to pick mushrooms! :mushroom: :mushroom: :mushroom:

Thank you very much!

from autumn in Japan yosuke