Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

unable to run rest api to fetch issues from jira

Vamsi Krishna Panthulu October 6, 2025

I am getting this error.  Not very good at scripting.  Taking assistance from GPT.

 

I want to fetch all issues from the project for a date range.  the ultimate goal is to fetch worklogs by author but even a simple list of issues is returning no results.  I confirmed by JQL in jira that there are issues for this query.

 

🔍 JQL Query: project = CSS AND created >= "2025-09-01" AND created <= "2025-09-10"
📦 Request Payload: {
"jql": "project = CSS AND created >= \"2025-09-01\" AND created <= \"2025-09-10\"",
"fields": [
"summary",
"status",
"created"
],
"pagination": {
"pageSize": 100
},
"reconcileIssues": true
}

📡 Response Status: 400
❌ Request failed: 400 Client Error: Bad Request for url: https://zlservicedesk.atlassian.net/rest/api/3/search/jql

✅ Downloaded 0 issues across 0 page(s).

-------------------------------------------------------------------------------

Script used

import requests
from requests.auth import HTTPBasicAuth
import json

# === Configuration ===
domain = "zlservicedesk.atlassian.net"
email = "myaddress@domain.com"
api_token = "my api key"
project_key = "CSS"
start_date = "2025-09-01"
end_date = "2025-09-10"

# === API Endpoint ===
url = f"https://{domain}/rest/api/3/search/jql"

# === JQL Query ===
jql_query = f'project = {project_key} AND created >= "{start_date}" AND created <= "{end_date}"'

# === Request Setup ===
auth = HTTPBasicAuth(email, api_token)
headers = {
"Accept": "application/json",
"Content-Type": "application/json"
}

# === Initial Payload ===
payload = {
"jql": jql_query,
"fields": ["summary", "status", "created"],
"pagination": {
"pageSize": 100
},
"reconcileIssues": True
}

# === Debug: Show Request Details ===
print("🔍 JQL Query:", jql_query)
print("📦 Request Payload:", json.dumps(payload, indent=2))

# === Fetch Issues ===
issues = []
next_page_token = None
page_count = 0

while True:
if next_page_token:
payload["nextPageToken"] = next_page_token

try:
response = requests.post(url, headers=headers, json=payload, auth=auth)
print(f"\n📡 Response Status: {response.status_code}")
response.raise_for_status()
data = response.json()

# Debug: Show raw response on first page
if page_count == 0:
print("📄 Raw Response (Page 1):", json.dumps(data, indent=2))

issues.extend(data.get("issues", []))
next_page_token = data.get("nextPageToken")
page_count += 1

if not next_page_token:
break

except requests.exceptions.RequestException as e:
print("❌ Request failed:", e)
break

print(f"\n✅ Downloaded {len(issues)} issues across {page_count} page(s).")

0 answers

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events