Trying to get all issues from JIRA cloud using the below code. But due to pagination I am unable to get more than 50 rows but I have a total of 500+ rows in data. I tried a lot to do a for loop but unable to get the output as JSON file with more than 50 rows. Please help.
I have to find the total number of records in the call and use the parameters startAt and maxResults to get the data. Kindly help me with pagination.
<span>import</span> requests
<span>from</span> requests.auth
<span>import</span> HTTPBasicAuth
<span>import</span> json
url = <span>"https://dataanalystteam.atlassian.net/rest/api/3/search"</span>
auth = HTTPBasicAuth(<span>"Email"</span>, <span>"API Token"</span>)
headers = {
<span>"Accept"</span>: <span>"application/json"</span>
}
query = {
<span>'jql'</span>: <span>'project = ITSAMPLE'</span>,<span>"startAt"</span>: <span>0</span>, <span>"maxResults"</span>: <span>500</span>
}
response = requests.request(
<span>"GET"</span>,
url,
headers=headers,
params=query,
auth=auth
)
<span>print</span>(json.dumps(json.loads(response.text), sort_keys=<span>True</span>, indent=<span>4</span>, separators=(<span>","</span>, <span>": "</span>)))