Hi.
I am trying to do something very simple.
#!/usr/bin/python
from jira import JIRA
options = { 'server' : 'http://x.x.x.x:9090'}
jira = JIRA(options,basic_auth=('username', 'password'))
projects = jira.projects()
print (projects)
And I get a lot of errors. How do I resolve this? I would paste it here, but this community flags it as SPAM and removes my post.
I am able to connect to JIRA and query issues using CURL command from shell prompt.
Hi @Max!
Do You use proxy? Maybe curl has correct proxy settings, but python not have?
And which type error: unauthorized, not connect, some 404 etc. ?
lot of errors
Try found first and resolve it, cus second, third ... - maybe depend from first.
Our company has a proxy. But if Curl works, then Python should work too, we are able to request a response using python requests module. It wasn't a 404 error. I will paste tomorrow the error.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Andrew, this is the error I get when I run the above script. (I masked the IP address with x.x.x.x)
C:\Dropbox\JIRA>python req_jira2.py
Traceback (most recent call last):
File "req_jira2.py", line 20, in <module>
jira = JIRA(options,basic_auth=('user', 'user'))
File "C:\Python3\lib\site-packages\jira\client.py", line 472, in __init__
si = self.server_info()
File "C:\Python3\lib\site-packages\jira\client.py", line 2133, in server_info
j = self._get_json('serverInfo')
File "C:\Python3\lib\site-packages\jira\client.py", line 2549, in _get_json
r = self._session.get(url, params=params)
File "C:\Python3\lib\site-packages\jira\resilientsession.py", line 151, in get
return self.__verb('GET', url, **kwargs)
File "C:\Python3\lib\site-packages\jira\resilientsession.py", line 147, in __verb
raise_on_error(response, verb=verb, **kwargs)
File "C:\Python3\lib\site-packages\jira\resilientsession.py", line 57, in raise_on_error
r.status_code, error, r.url, request=request, response=r, **kwargs)
jira.exceptions.JIRAError: JiraError HTTP 404 url: http://x.x.x.x:9090/rest/api/2/serverInfo
text: <!DOCTYPE html><html><head><title>Apache Tomcat/8.5.9 - Error report</title><style type="text/css">h1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} h2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} h3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} body {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} b {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} p {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;} a {color:black;} a.name {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style> </head><body><h1>HTTP Status 406 - </h1><div class="line"></div><p><b>type</b> Status report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers.</u></p><hr class="line"><h3>Apache Tomcat/8.5.9</h3></body></html>
response headers = {'Content-Type': 'text/html;charset=utf-8', 'Content-Language': 'en', 'Content-Length': '1102', 'Date': 'Mon, 29 Oct 2018 17:48:55 GMT'}
response text = <!DOCTYPE html><html><head><title>Apache Tomcat/8.5.9 - Error report</title><style type="text/css">h1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} h2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} h3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} body {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} b {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} p {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;} a {color:black;} a.name {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style> </head><body><h1>HTTP Status 406 - </h1><div class="line"></div><p><b>type</b> Status report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers.</u></p><hr class="line"><h3>Apache Tomcat/8.5.9</h3></body></html>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I also want to add in addition to 'curl' command working on cmd.exe shell prompt, I am also able to connect using the python 'requests' module. But we want/prefer to user 'jira' module.
The following script works,
import requests
url = "http://x.x.x.x/issue/rest/api/2/search?jql=project+in+('projectname')+AND+reporter+in+('username')"
response = (requests.get(url, auth=('username', 'username')).content)
data = json.loads(response)
But we want to use 'import jira' method' because as it turns out with 'requests', many customfields are ridiculously nested dictionaries which is next to impossible to work with.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You show request for different url:
I see port 9090 url: http://x.x.x.x:9090/rest/api/2/serverInfo
This port 80 url = "http://x.x.x.x/issue/rest/api/2/search
You need check at identical url.
HTTP 404 - page not, open this http://x.x.x.x:9090/rest/api/2/serverInfo and http://x.x.x.x/rest/api/2/serverInfo in browser.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
For some reason on the web browser 9090 works. But when CURL likes port 8080 when given from command prompt.
When I change to 8080 I get this warnings with no result still ... :
WARNING:root:HTTPConnectionPool(host='x.x.x.x', port=8080): Max retries exceeded with url: /rest/api/2/serverInfo (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x000002061B574B38>: Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond',)) while doing GET http://x.x.x.x:8080/rest/api/2/serverInfo [{'params': None, 'headers': {'User-Agent': 'python-requests/2.20.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='x.x.x.x', port=8080): Max retries exceeded with url: /rest/api/2/serverInfo (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x000002061B574B38>: Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond',))] errno:None on GET http://x.x.x.x:8080/rest/api/2/serverInfo
{'response': None, 'request': <PreparedRequest [GET]>}\{'response': None, 'request': <PreparedRequest [GET]>}
WARNING:root:Got recoverable error from GET http://x.x.x.x:8080/rest/api/2/serverInfo, will retry [1/3] in 11.439982646667415s. Err: HTTPConnectionPool(host='12.30.96.54', port=8080): Max retries exceeded with url: /rest/api/2/serverInfo (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x000002061B574B38>: Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond',))
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Max!
I'm confused. %-)
http://x.x.x.x/rest/api/2/serverInfo - it also port 80 - default port for http
Port 80, 8080, 9090 - You need to determine which is used JIRA java app.
For linux:
netstat -tulpn | grep <pid of java process>
or just netstat -tulpn and found some like 9090, 8080 etc.
Try request from server where is JIRA worked, example curl http://127.0.0.1:9090/... . If request worked from JIRA server, but not worked from another - check firewall and proxy.
web browser 9090 works
Then curl and python must work too. Check what proxy settings in Your browser and try set it for curl and python.
P.S. You forgot hide IP in the last log (Err: HTTPConnectionPool(host=) :-)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.