Forums

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

How do I get comments and custom fields from all issues in my project using python?

Noah F Wilson
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 30, 2025

I am trying to use the Jira Rest API to gather data from Jira tickets in my project using python. I want to be able to collect the comments, custom fields, and summary/key.

Trying to use the following code:

import pandas as pd
import requests
from requests.auth import HTTPBasicAuth
import json
from concurrent.futures import ThreadPoolExecutor

pat = "ACCESS TOKEN"
email = "EMAIL"

auth = HTTPBasicAuth(email, pat)

headers = {
  "Accept": "application/json",
  "Content-Type": "application/json"
}

base_payload = {
  "expand": [
    "names",
    "schema",
    "operations"
  ],
  "fields": [
    "key",
    "comment"
  ],
  "fieldsByKeys": False,
  "jql": 'project = PROJECT NAME',
  "maxResults": 100,
  "startAt": 0
}

def fetch_issues_chunk(start_at):
    payload = base_payload.copy()
    payload["startAt"] = start_at
    payload = json.dumps(payload)
   
    response = requests.request("POST", url, data=payload, headers=headers, auth=auth)
   
    if response.status_code != 200:
        print(f"Request failed with status code: {response.status_code}, message: {response.text}")
        return []
   
    data = response.json()
    return data.get("issues", [])

def fetch_all_issues(url, headers, base_payload, auth):
    initial_response = requests.request("POST", url, data=json.dumps(base_payload), headers=headers, auth=auth)
    if initial_response.status_code != 200:
        print(f"Initial request failed with status code: {initial_response.status_code}, message: {initial_response.text}")
        return []
   
    initial_data = initial_response.json()
    total = initial_data.get("total", 0)
    issues = initial_data.get("issues", [])
   
    with ThreadPoolExecutor() as executor:
        futures = [executor.submit(fetch_issues_chunk, start_at) for start_at in range(100, total, 100)]
        for future in futures:
            issues.extend(future.result())
   
    return issues

# Fetch all issues
issues = fetch_all_issues(url, headers, base_payload, auth)
And this continues to return a 400 code for me [Initial request failed with status code: 400, message: {"errorMessages":["Invalid request payload. Refer to the REST API documentation and try again."]}] and I am not sure why.. TIA

1 answer

0 votes
Sunny Ape
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 30, 2025

Hello @Noah F Wilson 

url = "https://MY_COMPANY.atlassian.net/rest/api/3/jql"

If you refer to the Jira Cloud REST API documentation, you will see there is no POST endpoint with the path /rest/api/3/jql

You probably should be using the Search for Issues using JQL (POST) endpoint which has the path /rest/api/3/search/jql

I recommend that you use an API test tool like Postman to validate your requests independently of your code.

Suggest an answer

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

Atlassian Community Events