Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

What server to use to connect python with jira api

This is my code:

from jira import JIRA

options = {'server': 'https://myaccount.atlassian.net'}
jira = JIRA(options, basic_auth=('username', 'password'))

and it says 

Got recoverable error from GET https://myaccount.atlassian.net/rest/api/2/serverInfo, will retry [1/3] in 3.51334302252s. Err: 401 Unauthorized

5 answers

0 votes
edwin Community Leader Jul 11, 2018

Hi @Amir Darbar,

401 error is related to authentication - possibly the wrong credentials.

I have ran across this when I have special characters in my password and it doesn't get parsed well in the script.

Try

from jira import JIRA
import getpass

password = getpass.getpass()

options = {'server': 'url'}
jira = JIRA(options, basic_auth=('username', password))

Hi, now I have a different error telling me:

WARNING:root:Got recoverable error from GET http://localhost:2990/jira/rest/api/2/serverInfo, will retry [1/3] in 9.84980195432s. Err: HTTPConnectionPool(host='localhost', port=2990): Max retries exceeded with url: /jira/rest/api/2/serverInfo (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x107467c90>: Failed to establish a new connection: [Errno 61] Connection refused',))

I think its a problem with the url I'm using in options, do you know which URL I have to use to connect to the data of my organization?

edwin Community Leader Jul 11, 2018

It should be the URL you're using to access JIRA. Also make sure it is the same URL set in your Base URL configuration.

@edwin  Even though using the base URL of my company I am getting 401 error and I don't have special char in my password also.

Can you please help me with this.

edwin Community Leader May 31, 2019

Hi @Ruchit

Passwords are deprecated for cloud applications. Please use app tokens.

Client must be authenticated to access this resource.

Hi @edwin 

I am trying to connect to "https://jira.mycompany.com" URL using python jira module.

For this do I need to use app token or I can use basic_auth.

edwin Community Leader May 31, 2019

@Ruchit basic_auth

Please check your credentials.

Another thing to try is

options = {'server': 'url', 'verify': False}

 There may be an issue with your SSL certificate.

hi @edwin 

 

I am trying to connect to jira using the same method ad it is saying that basic authentication with password is depreciated. 

I am tired searching for it but didn't get how to connect my code with jira.

This is what I a using

options = {'server''https://myaccount.atlassian.net'}   

 jira = JIRA(options, basic_auth=('username','my_password'))

@edwin  I have tried the above process which you mentioned. And I kept 'verify': False so

I am not using SSL CERTIFICATE. 

edwin Community Leader Jun 04, 2019

@Ruchit 

Are you still getting a 401 error?

@edwin 

Yes, I am getting 401 error. Can you please confirm that for testing purpose if 'verify': False i.e.

options = {'server': 'url', 'verify': False}

then SSL Certificate is not required?

Step by Step how to access the hosted Jira API via python

Using the JIRA python module this example works:

https://thepythoncoding.blogspot.com/2018/07/python-step-by-step-how-to-access.html

from jira import JIRA
jira = jira = JIRA(basic_auth=(un, pwd), options={'server': server})
issue = jira.issue('JRA-9')
print(issue.fields.project.key) # 'JRA'
print(issue.fields.issuetype.name) # 'New Feature'
print(issue.fields.reporter.displayName) # 'Mike Cannon-Brookes [Atlassian]'

If somebody still need a solution, you can install JIRA rest api : lib https://pypi.python.org/pypi/jira/. Just a simple example:

https://thepythoncoding.blogspot.com/2019/06/what-server-to-use-to-connect-python.html

from jira.client import JIRA

jira_server = "http://yourjiraserver.com"
jira_user = "login"
jira_password = "pass"

jira_server = {'server': jira_server}
jira = JIRA(options=jira_server, basic_auth=(jira_user, jira_password))

group = jira.group_members("jira-users")
for users in group:
print users

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you