Created
April 29, 2025 13:06
-
-
Save justaguywhocodes/f8d829567aa29e8c2347cf2c4f9622ef to your computer and use it in GitHub Desktop.
Jira
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from requests.auth import HTTPBasicAuth | |
import json | |
# Jira instance URL and credentials | |
JIRA_URL = "https://your-jira-instance.atlassian.net" | |
EMAIL = "[email protected]" | |
API_TOKEN = "your-api-token" | |
# Issue key | |
ISSUE_KEY = "CIBETHICAL-123" | |
# API endpoint for issue details | |
url = f"{JIRA_URL}/rest/api/2/issue/{ISSUE_KEY}" | |
# Set up authentication | |
auth = HTTPBasicAuth(EMAIL, API_TOKEN) | |
# Set headers | |
headers = { | |
"Accept": "application/json" | |
} | |
try: | |
# Make the GET request | |
response = requests.get(url, headers=headers, auth=auth) | |
# Check if the request was successful | |
response.raise_for_status() | |
# Parse the JSON response | |
issue_data = response.json() | |
# Print the issue details | |
print(json.dumps(issue_data, indent=2)) | |
except requests.exceptions.HTTPError as http_err: | |
print(f"HTTP error occurred: {http_err}") | |
except requests.exceptions.RequestException as err: | |
print(f"Error fetching issue: {err}") | |
except ValueError as json_err: | |
print(f"Error parsing JSON response: {json_err}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment