Hello. I am facing issues while trying to make GET calls using Jira REST APIs via python scripting. It was working fine until the older APIs were deprecated. Based on the documentation - The Jira Cloud platform REST API, I tried writing a code snippet to simply fetch issues based on a query. It fails to provide any response. I am not sure what is it that I am doing incorrectly. Can someone please help and suggest a fix? Thanks!
Below is the code snippet:
import requests
from urllib.parse import quote
# Jira Cloud details
JIRA_URL = "<Cloud URL>"
API_TOKEN = "<API_TOKEN>"
EMAIL = "<EMAIL>"
JQL = "project = DPLY and fixversion = '2025-Q4'" # Example JQL
# Encode the JQL query
encoded_jql = quote(JQL)
# Pagination settings
start_at = 0
max_results = 50 # Adjust as needed
headers = {
"Authorization": f"Basic {requests.auth._basic_auth_str(EMAIL, API_TOKEN)}",
"Accept": "application/json"
}
while True:
url = f"{JIRA_URL}/rest/api/3/search/jql?jql={encoded_jql}&startAt={start_at}&maxResults={max_results}"
response = requests.get(url, headers=headers)
data = response.json()
issues = data.get("issues", [])
if not issues:
break
for issue in issues:
print(issue["key"], issue["fields"]["summary"])
start_at += max_results
if start_at >= data.get("total", 0):
break