There seems to be several jira api available on python library:
1. from jira import JIRA (does not work)
2. from atlassian import Jira (work)
If I use the jira from JIRA package like following to login, it faults:
jira = JIRA(basic_auth=(\
JIRA_SERVER_AUTH_BASIC[JIRA_SERVER_PROFILE].split()[0].strip(), \
JIRA_SERVER_AUTH_BASIC[JIRA_SERVER_PROFILE].split()[1].strip()))
and I am getting following errors when trying to connect:
Using jira library
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 0x7f4cae23c048>: Failed to establish a new connection: [Errno 111] Connection refused',)) while doing GET http://localhost:2990/jira/rest/api/2/serverInfo [{'params': None, 'headers': {'User-Agent': 'python-requests/2.21.0', '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'}}]
WARNING:root:Got ConnectionError [HTTPConnectionPool(host='localhost', port=2990): Max retries exceeded with url: /jira/rest/api/2/serverInfo (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f4cae23c048>: Failed to establish a new connection: [Errno 111] Connection refused',))] errno:None on GET http://localhost:2990/jira/rest/api/2/serverInfo
{'response': None, 'request': <PreparedRequest [GET]>}\{'response': None, 'request': <PreparedRequest [GET]>}
WARNING:root:Got recoverable error from GET http://localhost:2990/jira/rest/api/2/serverInfo, will retry [1/3] in 6.9469562842627175s. Err: HTTPConnectionPool(host='localhost', port=2990): Max retries exceeded with url: /jira/rest/api/2/serverInfo (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f4cae23c048>: Failed to establish a new connection: [Errno 111] Connection refused',))
^CTraceback (most recent call last):
But atlassian package seems to work at least login part and retrieve project information:
jira = Jira(
url=JIRA_SERVER_IP[JIRA_SERVER_PROFILE],
username=JIRA_SERVER_AUTH_BASIC[JIRA_SERVER_PROFILE].split()[0].strip(),
password=JIRA_SERVER_AUTH_BASIC[JIRA_SERVER_PROFILE].split()[1].strip())
#JQL = 'project = gg-proj-000 AND status IN ("To Do", "In Progress") ORDER BY issuekey'
JQL = 'project = gg-proj-000'
data = jira.jql(JQL)
output:
Using atlassian library...
<class 'str'>
Why the first one working? Which package is more prominent and widespread usage?
Not sure if you ever got to the bottom of this, but here is my solution. BTW. I agree that the examples on https://jira.readthedocs.io/ are confusing (and just plain wrong!)
from jira import JIRA
options = {
'server': 'https://<JIRA server>',
'verify': False # Not recommended. I only did this because my certs were messed up!!
}
jira = JIRA(options=options, basic_auth=("<User Name>", "<password>"))
#Get one story and print out some stuff to show it worked
issue = jira.issue(id='<issue/story ID>')
print ( issue.key)
print ( issue.fields.summary)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
it seems, you need to configure your baseurl for the Server when using the jira module, are you connecting to a Cloud Instance or a Self-hosted Instance?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
here is the slight correction and resulting output. In this one, now correct http url and port code + authenticaion (basic) used however still connection failure:
I can access through browser the jira server fine so it should not be a cause of problem but somehow example below fails. And it is most basic example/syntax I used from jira python tutorial:
https://jira.readthedocs.io/en/master/
and it does not work. Shame on Atlassian!
jira = JIRA('https://' + JIRA_SERVER_IP[JIRA_SERVER_PROFILE], basic_auth=(\
JIRA_SERVER_AUTH_BASIC[JIRA_SERVER_PROFILE].split()[0].strip(), \
JIRA_SERVER_AUTH_BASIC[JIRA_SERVER_PROFILE].split()[1].strip()))
oot@sriov-guest:/git.co/dev-learn/jira# ./jira-access-pilot.py
Loggin into: http://192.168.122.200:8080
Logging with: ggjira300, | ********
Using jira library
WARNING:root:HTTPSConnectionPool(host='http', port=443): Max retries exceeded with url: //192.168.122.200:8080/rest/api/2/serverInfo (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f1fe43ecef0>: Failed to establish a new connection: [Errno -2] Name or service not known',)) while doing GET https://http://192.168.122.200:8080/rest/api/2/serverInfo [{'params': None, 'headers': {'User-Agent': 'python-requests/2.18.4', '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'}}]
WARNING:root:Got ConnectionError [HTTPSConnectionPool(host='http', port=443): Max retries exceeded with url: //192.168.122.200:8080/rest/api/2/serverInfo (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f1fe43ecef0>: Failed to establish a new connection: [Errno -2] Name or service not known',))] errno:None on GET https://http://192.168.122.200:8080/rest/api/2/serverInfo
{'response': None, 'request': <PreparedRequest [GET]>}\{'response': None, 'request': <PreparedRequest [GET]>}
WARNING:root:Got recoverable error from GET https://http://192.168.122.200:8080/rest/api/2/serverInfo, will retry [1/3] in 7.790048839473105s. Err: HTTPSConnectionPool(host='http', port=443): Max retries exceeded with url: //192.168.122.200:8080/rest/api/2/serverInfo (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f1fe43ecef0>: Failed to establish a new connection: [Errno -2] Name or service not known',))
WARNING:root:HTTPSConnectionPool(host='http', port=443): Max retries exceeded with url: //192.168.122.200:8080/rest/api/2/serverInfo (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f1fe44045c0>: Failed to establish a new connection: [Errno -2] Name or service not known',)) while doing GET https://http://192.168.122.200:8080/rest/api/2/serverInfo [{'params': None, 'headers': {'User-Agent': 'python-requests/2.18.4', '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'}}]
WARNING:root:Got ConnectionError [HTTPSConnectionPool(host='http', port=443): Max retries exceeded with url: //192.168.122.200:8080/rest/api/2/serverInfo (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f1fe44045c0>: Failed to establish a new connection: [Errno -2] Name or service not known',))] errno:None on GET https://http://192.168.122.200:8080/rest/api/2/serverInfo
{'response': None, 'request': <PreparedRequest [GET]>}\{'response': None, 'request': <PreparedRequest [GET]>}
WARNING:root:Got recoverable error from GET https://http://192.168.122.200:8080/rest/api/2/serverInfo, will retry [2/3] in 7.508035309262091s. Err: HTTPSConnectionPool(host='http', port=443): Max retries exceeded with url: //192.168.122.200:8080/rest/api/2/serverInfo (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f1fe44045c0>: Failed to establish a new connection: [Errno -2] Name or service not known',))
^CTraceback (most recent call last):
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey @guyengn
On a side note are you aware that this Library is not written by Atlassian? For this error, there seems to be a problem on the URL.
https://http://192.168.122.200:8080/rest/api/2/serverInfo
it should not be https://http:// so remove the http:// as the code already adds a https://
jira = JIRA('https://' + JIRA_SERVER_IP[JIRA_SERVER_PROFILE],basic_auth=(\
JIRA_SERVER_AUTH_BASIC[JIRA_SERVER_PROFILE].split()[0].strip(), \
JIRA_SERVER_AUTH_BASIC[JIRA_SERVER_PROFILE].split()[1].strip()))
going through the doc for Basic Auth, you might want to alter the code from using https:// and stick to http:// only, as your connection in your localhost is running on http.
jac = "http://192.168.122.200:8080/rest/api/2/serverInfo"
jira = JIRA(jac, basic_auth=(\
JIRA_SERVER_AUTH_BASIC[JIRA_SERVER_PROFILE].split()[0].strip(), \
JIRA_SERVER_AUTH_BASIC[JIRA_SERVER_PROFILE].split()[1].strip()))
I'm Assuming that the JIRA_SERVER_AUTH_BASIC variables are extracted from somewhere in your code. I recommend you basically just remove such variable and simply add the username and password to see if this connection works because the error basically states that it cannot connect.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, thanks for pointing the http:// prefix, now that is removed, it is almost working. Almsot.
ssl version conflict error:
I know username and password works because when the same variables used in atlassian-jira package, login works ok to the same jira server specified. With that, here is the output:
WARNING:root:HTTPSConnectionPool(host='192.168.122.200', port=8080): Max retries exceeded with url: /rest/api/2/serverInfo (Caused by SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:852)'),)) while doing GET https://192.168.122.200:8080/rest/api/2/serverInfo [{'params': None, 'headers': {'User-Agent': 'python-requests/2.18.4', '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 did google about ssl error it is not pretty, i guess i will try and keep digging on this one.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
you shouldn't be using https, why not simply use http that's why it defaults to use https in the request library and you're not running an ssl enabled installation on localhost hence the error. change that to http://192.168.122.200:8080/rest/api/2/serverInfo instead.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
i changed to http, but login still fails. There is somewhere information about 401 error which appears to be simple login after certain version does not allow AND advises to use API token. But instruction on API token setting does not match with what I deployed and I can not find anywhere to configure because
WARNING:root:Got recoverable error from GET http://192.168.122.200:8080/rest/api/2/serverInfo, will retry [1/3] in 6.163836010755226s. Err: 401
which led me here:
https://support.aha.io/hc/en-us/articles/115002476386
But this instruction does nto work because there is no such thing as setting->workplace and spent an hour searching fruitlessly through its mind boggling menu navigation.
"Navigate to Settings ⚙️ > Workspace and select your Jira integration."
Why atlassian always publish help, menu navigation and every time I try?
I just have to use jira at work otherwise I will dump this crap from using.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Looks like I am not alone with this jira crap
https://community.atlassian.com/t5/Jira-questions/Unable-to-connect-to-JIRA-from-python/qaq-p/817210
Mindboggling they can not even get the login working.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
wHY cant i see the api token authentication setting on my setup?
atlassian creating help that does not exist on actual product!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.