I am trying to access jira from python at my work place and the basic operation I intend to do is to fetch/create/update jira issues. I looked at the template code online and am trying to use that, but no luck. I have already installed jira api using pip.
pip install jira
#!/usr/bin/python
from jira import JIRA
options = {'server' : 'https://jira.mycompany.com/rest/api/2'}
jira = JIRA(options)
projects = jira.projects()
print (projects)
And this is its output:
Traceback (most recent call last):
File "JiraTest.py", line 7, in <module>
jira = JIRA(options)
File "C:\Anaconda3\lib\site-packages\jira\client.py", line 317, in __init__
si = self.server_info()
File "C:\Anaconda3\lib\site-packages\jira\client.py", line 1771, in server_info
j = self._get_json('serverInfo')
File "C:\Anaconda3\lib\site-packages\jira\client.py", line 2172, in _get_json
r = self._session.get(url, params=params)
File "C:\Anaconda3\lib\site-packages\jira\resilientsession.py", line 150, in get
return self.__verb('GET', url, **kwargs)
File "C:\Anaconda3\lib\site-packages\jira\resilientsession.py", line 146, in __verb
raise_on_error(response, verb=verb, **kwargs)
File "C:\Anaconda3\lib\site-packages\jira\resilientsession.py", line 56, in raise_on_error
r.status_code, error, r.url, request=request, response=r, **kwargs)
jira.exceptions.JIRAError: JiraError HTTP 404 url:https://jira.mycompany.com/rest/api/2/rest/api/2/serverInfo
response headers = {'Date': 'Sat, 29 Jul 2017 22:42:31 GMT', 'Content-Length': '0', 'Server': 'Apache-Coyote/1.1'}
response text =
` I know I am doing something wrong here and hence this are the things I want to ask:
- How to determine jira server at your work place.
- Do the jira administrator need to enable rest api calls or something else from admin login? Is there a way to determine if it is disabled from our code?
- Is there anything else I have to install apart from just installing jira through pip.
- How to deal with login credentials. I am sure there is a better way than specifying username/password in your .py file. Can someone point me on where to find that info.
Thanks.