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

JIRA cloud returning issue to python

Edited

Hi, the following code is not working for me. I returns an object, but then I cannot query the fields of hte object, or the object is the wrong object type. Any suggestions would be appreciated. Environment : Anaconda Python, JIRA Cloud.

from jira.client import JIRA
import traceback

print("Start")
issue=None

def tryJIRAConnect(issue):
jira_options = {'server': 'https://l8c.atlassian.net'}
try:
jira = JIRA(options=jira_options, basic_auth=('xxx.xxx@xxx.com', 'xxxxxxxxxx'))
issue=jira.issue('xxxDEV-1')
print(f'Success : JIRA Issue is : {issue}')
return(issue)
except Exception as e:
print(e)
traceback.print_exc()

x = tryJIRAConnect(issue)
print(f'x is : {type(x)}')

try:
print(x.raw)
except Exception as e:
print(e)
traceback.print_exc()

Wa expecting the issue details in this object,looks like the server connectionto me.

'baseUrl': 'https://xxx.atlassian.net', 'version': '1001.0.0-SNAPSHOT', 'versionNumbers': [1001, 0, 0], 'deploymentType': 'Cloud', 'buildNumber': 100187, 'buildDate': '2022-01-05T14:01:29.000+0100', 'serverTime': '2022-01-08T12:33:41.914+0100', 'scmInfo': '07b4f58ec2724461528057c7cbdf73a2f653f223', 'serverTitle': 'Jira', 'defaultLocale': {'locale': 'en_US'}}

 

1 answer

1 accepted

2 votes
Answer accepted
Pramodh M Community Leader Jan 08, 2022

Hi @Andrew Sear 

Welcome to the community!!

How about you use this API and let me know the feedback

This one is flexible

https://atlassian-python-api.readthedocs.io/index.html

Being said that, the error might be related to Link provided is not correct, can you try with only till .net and then see if you can access the issue object

It should return all the dat related to issue that you are querying

Thanks,

Pramodh

Thanks, changing the url link certainly helped, I can now see a lot of details with the issue retrieved.  I will move on to the next step :-). Thanks for the answer. I will also take a look at the API you have suggested.

Like Pramodh M likes this

Also tried the api you suggested... 5 minutes later, and it returns the necessary value. Thanks for the suggestion.

So the API seems good. I am testing on JIRA Cloud, but work has JIRA Server with greenhopper.  Is there any way to get a sprint report from JRIA Cloud as a JSON response, similar to what can be done with JIRA Server and greenhopper? Or is this ability not availble with JRIA Cloud? If so, what would be the equivalent? For various reasons I am extracting the sprint reports to json files, then summarizing and merging the data, for display in Tableau.

Like Andrew Sear likes this

Thanks, I have been trying that one, stuck with authentication problem error 401. Using the same credentials that work with the jira api you reference earlier.

url = "https://xxx.atlassian.net/rest/agile/1.0/sprint/xxx_1.1"

cred = "Basic " + base64.b64encode(b'xxxx.xxxxxx@gmail.com:xxxxxxxxx').decode("utf-8")

headers = {
"Accept": "application/json",
"Content-Type": "application/json",
"Authorization": "cred"
}


response = requests.request(
"GET",
url,
headers=headers
)

 

Error message is : 

{"message":"Client must be authenticated to access this resource.","status-code":401}

Is the password from the same as the token used in the other API? Or is it the password I used to create the jira project?

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
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