Unable to make a JIRA Object using the Python library

Hi, I'm running this bit of code trying to make a jira object:

#!/usr/local/bin/python3.6
import jira.client
from jira.client import JIRA
jira = JIRA()

And this is returning a huge number of warnings and errors, all of which read something like this: 

WARNING:root:HTTPConnectionPool(host='localhost', port=2990): Max retries exceeded with url: /jira/rest/api/2/serverInfo (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x1044479e8>: Failed to establish a new connection: [Errno 61] Connection refused',)) while doing GET http://localhost:2990/jira/rest/api/2/serverInfo [{'params': None, 'headers': {'User-Agent': 'python-requests/2.18.1', 'Accept-Encoding': 'gzip, deflate', 'Accept': 'application/json,*.*;q=0.9', 'Connection': 'keep-alive', 'Cache-Control': 'no-cache', 'Content-Type': 'application/json', 'X-Atlassian-Token': 'no-check'}}]

 

I'm trying to figure out what the issue is, as I'd pretty much lifted the code from the documentation. Any help would be greatly appreciated!

 

1 answer

Hi Ross,

There are a couple things here:

I see you're being connected to port 2990 and getting a connection refused:

Failed to establish a new connection: [Errno 61] Connection refused',)) while doing GET http://localhost:2990/jira/rest/api/2/serverInfo

I was getting the same error initially until I saw this in the jira-python API documentation which lists the following as the default options:

DEFAULT_OPTIONS =
{'async': False,
'rest_api_version': '2',
'verify': True,
'agile_rest_path': 'greenhopper',
'server': 'http://localhost:2990/jira',
'rest_path': 'api',
'check_update': False,
'agile_rest_api_version':
'1.0', 'client_cert': None,
context_path': '/',
'headers': {'X-Atlassian-Token': 'no-check', 'Cache-Control': 'no-cache', 'Content-Type': 'application/json'},
'resilient': True}

In the Examples section it states:

By default, the client will connect to a JIRA instance started from the Atlassian Plugin SDK

You can override the above options with the override this with the options parameter.

I did get it working using the following:

from jira import JIRA
options = {'server':'http://localhost:8080'}
jira = JIRA(options, basic_auth=('UN', 'PW'))

Hopefully that helps!

P.S.  Can you also tell me which documentation you're looking at?  I've seen a lot of jira.client calls lately and I wanted to know where that was coming from.

Cheers,

Branden

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,203 views 13 19
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot