Forums

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

issue while fetching jira issues using {JIRA_URL}/rest/api/3/search/jql"

npatil October 22, 2025
Giving 0 issues while running below - 
import requests
import json
from requests.auth import HTTPBasicAuth

# --- Configuration ---
JIRA_URL = "https://tracelink.jira.com/" # Replace with your Jira Cloud domain
JIRA_EMAIL = "myEmail@myCompany.com" # Replace with your Jira email
JIRA_API_TOKEN = "XXXXXX" # Replace with your Jira API token


# --- API Endpoint ---
JIRA_API3_SEARCH_ENDPOINT = f"{JIRA_URL}/rest/api/3/search/jql"

# --- Authentication ---
auth = HTTPBasicAuth(JIRA_EMAIL, JIRA_API_TOKEN)

# --- Headers ---
HEADERS = {
"Accept": "application/json",
"Content-Type": "application/json"
}

def search_jira_issues(jql_query, max_results=50, fields=None):
"""
Searches Jira issues using a JQL query.

Args:
jql_query (str): The JQL query string.
max_results (int): The maximum number of results to return per page.
fields (list, optional): A list of fields to include in the response.
Defaults to None (all fields).

Returns:
dict: The JSON response containing the search results.
"""
payload = {
"jql": jql_query,
"maxResults": max_results,
}
if fields:
payload["fields"] = fields

try:
response = requests.post(
JIRA_API3_SEARCH_ENDPOINT,
headers=HEADERS,
data=json.dumps(payload),
auth=auth
)
response.raise_for_status() # Raise an exception for bad status codes
print(response.json())
return response.json()
except requests.exceptions.RequestException as e:
print(f"Error searching Jira issues: {e}")
return None

# --- Example Usage ---
if __name__ == "__main__":
# Example 1: Search for issues in a specific project
jql = "project = 'TL' ORDER BY created DESC"
issues_data = search_jira_issues(jql, max_results=10)

if issues_data:
print("Issues found:")
for issue in issues_data.get("issues", []):
print(f"- {issue['key']}: {issue['fields']['summary']}")

print("\n" + "="*30 + "\n")

# Example 2: Search for issues with a specific status and retrieve only key and summary
jql_status = "status = 'Done' AND project = 'TL'"
fields_to_retrieve = ["key", "summary"]
done_issues_data = search_jira_issues(jql_status, max_results=5, fields=fields_to_retrieve)

if done_issues_data:
print("Done issues found (key and summary only):")
for issue in done_issues_data.get("issues", []):
print(f"- {issue['key']}: {issue['fields']['summary']}")

1 answer

0 votes
Tuncay Senturk _Snapbytes_
Community Champion
October 23, 2025

Are you using the correct domain? It should be https://<site>.atlassian.net 

 

npatil October 24, 2025

yes, Its correct - 

Error searching Jira issues: 404 Client Error: Not Found for url: https://tracelink.atlassian.net/rest/api/3/search/jql

 

Tuncay Senturk _Snapbytes_
Community Champion
October 25, 2025

Ok, make sure that you 

1. remove the backslash at the end, otherwise you'll have double backslash in the URL

JIRA_URL = "https://tracelink.atlassian.net"

2. Add "nextpageToken": null to the payload (for the first page it is null, but if you have more than max results you will need to get other pages as long as nextPageToken is not null.

 

Suggest an answer

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

Atlassian Community Events