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
Hi!
Might I suggest a different approach? I use the atlassian-python-api package:
import json
import pandas as pd
from atlassian import Jira
# === Authenticate using API token ===
jiraSandbox = Jira(
url=JIRA_BASE_URL,
username=EMAIL,
password=API_TOKEN
)
JQL_getIssues = "project = XYZ"
all_issues = []
start_at = 0
while True:
print(f"Fetched {start_at}")
jql_resp = jiraSandbox.jql(JQL_getIssues, start=start_at, limit=100)
issues = jql_resp.get('issues', [])
if not issues:
break
all_issues.extend(issues)
start_at += len(issues)
if start_at >= jql_resp.get('total', 0):
break
print(f"Total Fetched {len(all_issues)}")
Link to the documentation of the api:
https://pypi.org/project/atlassian-python-api/
Give it a try!
Hi @Jeroen Poismans . Thanks for sharing a sample snippet. I got the below error when I tried to run it:
New Jira API documentation - The Jira Cloud platform REST API
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hm, that is weird, the atlassian-python-api is still maintained and updated, but this change is apparently not in it yet. Let me check on that.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.