To retrieve Epic details from Jira using Python, you can follow the below process:
Here is a sample code snippet that demonstrates the above process:
import requests
import json
# Set the Jira URL and the Jira API token
JIRA_URL = 'https://your-jira-domain.atlassian.net/rest/api/3'
JIRA_API_TOKEN = 'your-jira-api-token'
# Define the endpoint URL for retrieving the Epic details in Jira
ENDPOINT_URL = JIRA_URL + '/search'
# Define the JQL (Jira Query Language) to retrieve the Epic details
JQL = 'issuetype=Epic'
# Set the headers and the parameters
headers = {
"Accept": "application/json",
"Content-Type": "application/json"
}
params = {
"jql": JQL,
"fields": "key,summary"
}
# Send a GET request to the endpoint URL using the requests module
response = requests.get(ENDPOINT_URL, params=params, auth=("username", JIRA_API_TOKEN), headers=headers)
# Parse the response JSON data using the json module
json_data = json.loads(response.text)
# Extract the required Epic details from the JSON data
for issue in json_data['issues']:
print("Key:", issue['key'], "Summary:", issue['fields']['summary'])
Note that you need to replace the JIRAURL, JIRAAPI_TOKEN, and the 'username' placeholder in the authentication with your actual Jira URL, Jira API token, and Jira username respectively. Also, you can specify the required fields in the params variable to retrieve additional details of the Epics.
Asked: 2022-01-30 11:00:00 +0000
Seen: 7 times
Last updated: Apr 01 '22