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

How to View issue using JIRA SERVER API?(Through python)

I am new to Atlassian product(JIRA).So far I have tried multiple jira "CLOUD" api through python.And it works perfectly. Now I want to try the same API in jira "SERVER".

My doubt is?
1.Can I use the same code(jira cloud api) in server or it is going be completely different.If it is different please guide me regarding that.
2.Only the auth process is different for both cloud & server.

#I am attaching my jira cloud api code(python) using HTTP Auth.

import requests
import json
from requests.auth import HTTPBasicAuth
auth = HTTPBasicAuth("username", "Api_Token")
def View():

key=input("issuekey/issueid")
url = "https://domain.atlassian.net/rest/api/3/issue/"+key

headers = {
"Accept": "application/json"
}

response = requests.request(
"GET",
url,
headers=headers,
auth=auth
)
#This is working perfectly in case of viewing the details of an issue(Jira cloud api).


How do I modify the same code to work in jira server api?

1 answer

1 vote
Pramodh M Community Leader Jan 05, 2022

Hi @Indumathi S 

Welcome to Community!!

Use the Python wrapper API - https://atlassian-python-api.readthedocs.io/

Available with both Server & Cloud

Issues link below

https://atlassian-python-api.readthedocs.io/jira.html#manage-issues

Authentication is as below

https://atlassian-python-api.readthedocs.io/#other-authentication-methods

 

Let me know if you have any queries


Thanks,
Pramodh

Hi @Pramodh M 

I tried to create a issue(JIRA-SERVER) using py client lib.

from jira import JIRA
auth_jira = JIRA(basic_auth=('username', 'password'))
jac = JIRA('https://domain.atlassian.net')
new_issue = jac.create_issue(project='project key', summary='New issue from jira-python',
description='Look into this one', issuetype={'name': 'Bug'}) 

 I am getting error like:

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 0x0000021175DD4220>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it')) while doing GET http://localhost:2990/jira/rest/api/2/serverInfo
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 0x0000021175DD4220>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it'))] errno:None on GET http://localhost:2990/jira/rest/api/2/serverInfo
{'response': None, 'request': <PreparedRequest [GET]>}
{'response': None, 'request': <PreparedRequest [GET]>}

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