0

I want to gather all jira issues via REST API.

My current code gets the first 100 rows of data because atlassian limits 100 rows per request.

Now, I have more than 500 rows but I don't know how to get them all instead of only 100 rows:

from collections import Counter
from jira import JIRA
import csv


jira = JIRA(basic_auth=('foo@gmail.com', 'mypassw'), options={'server': 'https://myjira.atlassian.net'})

daten = [issue.key + ';' + str(issue.fields.status) + ';' + issue.fields.summary + ';' + str(issue.fields.customfield_10121) + ';' + '\n' for issue in jira.search_issues('project=dt', maxResults=100)]

daten_enc = u''.join((daten)).encode('utf-8').strip()

print daten_enc

Output is e.g.:

  • DT-1469;Done;My Summary;ServiceDesk 1;

  • DT-1468;Done;My Summary;ServiceDesk 2;

  • DT-1467;Done;My Summary;ServiceDesk 3;

So, it is possible to add a jql query in

jira.search_issues('project=dt & issuekey < issue.key', maxResults=100)

But issue.key should be the last row of 100 rows (e.g. DT-1476).

I need to count 100 rows and then take the last issue.key to add in the above jql query

(jira.search_issues('project=dt & issuekey < issue.key.variable', maxResults=100)
Seko
  • 13
  • 1
  • 9
  • It is unclear, if you want to get all the JIRA issues or you want to perform some search and based on the search you want to get the entire result set? – N00b Pr0grammer Feb 09 '18 at 03:18
  • I want to get all Jira issues. But it is only possible if you modify the search criteria because you can only get 100 issues per request. My current code tries to get all issues but it gets only 100 from 500. So solution would be to fetch 100 issues and then take the issue key of the last of the 100 and put it in the search (jql) query in the code like "project=dt & issuekey < "last issuekey of the 100"' – Seko Feb 09 '18 at 12:41
  • You can check this answered question on JIRA forums, this should help you -> https://community.atlassian.com/t5/Answers-Developer-Questions/How-to-do-pagination-on-JIRA-Rest-api/qaq-p/516052 – N00b Pr0grammer Feb 12 '18 at 10:36
  • 1
    You can use the the `startAt` and `maxResults` values as appropriate – N00b Pr0grammer Feb 12 '18 at 10:36

1 Answers1

0

If you use maxResults=0, search_issues will do the pagination for you to retrieve all records for the search request.

Shrike
  • 1