Python script to check issue status in JIRA: Connection troubles

Hey everyone, I’m having a hard time getting my Python script to work with JIRA. I’m trying to fetch the status of an issue, but I keep running into connection problems. Here’s what I’ve tried so far:

from jira import JIRA

connection_settings = {
    'server': 'https://example.com:1234/',
    'verify': '/path/to/certificate.pub'
}
jira_client = JIRA(connection_settings, basic_auth=('myusername', 'mypassword'))

When I run this, I get a bunch of warning messages about SSL errors and the script can’t connect to the JIRA server. I’ve also tried setting ‘verify’ to False, but then I just get different warnings about insecure HTTPS requests.

I’m pretty stuck here. Does anyone know what I might be doing wrong or how I can fix this? Maybe there’s a problem with my SSL setup or the way I’m configuring the JIRA client? Any help would be awesome!

I’ve dealt with similar JIRA connection issues before, and it can be frustrating. One thing that worked for me was explicitly specifying the SSL protocol version. Try modifying your connection settings like this:

import ssl
from jira import JIRA

connection_settings = {
    'server': 'https://example.com:1234/',
    'options': {'verify': '/path/to/certificate.pub'},
    'ssl_context': ssl.create_default_context()
}
jira_client = JIRA(connection_settings, basic_auth=('myusername', 'mypassword'))

This approach forces the use of the default SSL context, which often resolves certificate validation problems. If you’re still having issues, you might need to update your SSL certificates or check if your JIRA server’s SSL configuration is correct. Don’t forget to ensure your Python environment has up-to-date SSL libraries too.

have u tried using requests library instead? sometimes it’s easier to handle ssl stuff. here’s a quick example:

import requests
url = 'https://example.com:1234/rest/api/2/issue/KEY-123'
response = requests.get(url, auth=('user', 'pass'), verify=False)
print(response.json())

might help bypass those ssl warnings. good luck!

I encountered similar issues when working with JIRA’s API. Have you considered using the atlassian-python-api library? It’s often more reliable for JIRA interactions. Here’s a snippet that might help:

from atlassian import Jira

jira = Jira(
    url='https://example.com:1234',
    username='myusername',
    password='mypassword',
    verify_ssl=False  # Use with caution in production
)

issue = jira.issue('KEY-123')
status = issue['fields']['status']['name']
print(f'Issue status: {status}')

This approach often bypasses SSL issues. If you still face problems, check your network settings and firewall rules. Sometimes corporate networks block these connections. Also, ensure your JIRA instance is accessible from your current network.