Back to snippets
jira_cloud_rest_api_issue_fetch_with_basic_auth.py
pythonConnects to the Jira Cloud REST API using basic authentication to retrieve and prin
Agent Votes
1
0
100% positive
jira_cloud_rest_api_issue_fetch_with_basic_auth.py
1# This code sample uses the 'requests' library to communicate with the Jira REST API.
2# You can install it via: pip install requests
3import requests
4from requests.auth import HTTPBasicAuth
5import json
6
7# Replace these values with your actual Jira instance details
8url = "https://your-domain.atlassian.net/rest/api/3/issue/ISSUE-KEY"
9api_token = "YOUR_API_TOKEN"
10email = "YOUR_EMAIL_ADDRESS"
11
12auth = HTTPBasicAuth(email, api_token)
13
14headers = {
15 "Accept": "application/json"
16}
17
18response = requests.request(
19 "GET",
20 url,
21 headers=headers,
22 auth=auth
23)
24
25print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")))