Giving 0 issues while running below -
import requests
import json
from requests.auth import HTTPBasicAuth
JIRA_EMAIL = "myEmail@myCompany.com" # Replace with your Jira email
JIRA_API_TOKEN = "XXXXXX" # Replace with your Jira API token
JIRA_API3_SEARCH_ENDPOINT = f"{JIRA_URL}/rest/api/3/search/jql"
auth = HTTPBasicAuth(JIRA_EMAIL, JIRA_API_TOKEN)
HEADERS = {
"Accept": "application/json",
"Content-Type": "application/json"
}
def search_jira_issues(jql_query, max_results=50, fields=None):
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
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")
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.