Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Different Python API's produce different results

Adam Balgach
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 28, 2023

Hi!  I have noticed there are two python package APIs that seem to be referenced here:

I am not sure which is the official version, since they seem to be interchangeable.  I have a basic cloud instance, and when trying to get a simple list of projects, I noticed one works, and one does not.  I have created an API token via the website under the profile -> api tokens section.  here is my code:

from atlassian import Jira
api_token = '<some token>'
prod_url = 'https://mysubnet.atlassian.net'

jira = Jira(
url=prod_url,
token=api_token,
cloud=True)

print(jira.projects())
print(jira.get_all_projects())

#returns [] an empty list

now if i use the other package:

from jira import JIRA
jira = JIRA(prod_url,
basic_auth=('user@domain.com', api_token))

print([x.key for x in jira.projects()])

#returns [proj_key1, proj_key2, proj_key3] as expected 

with the 2nd package (jira) I get the expected response.  with the first package I get an empty list.  Is there something I am doing wrong with the atlassian-python-api ?  This seems weird, but its my first attempt at using the python connector and am wondering what the best practices are.

 

Thanks-

1 answer

0 votes
Mohamed Benziane
Community Champion
April 29, 2023

Hi,

none of them are maintened by Atlassian, so you need to look at the github repo to look for the most up to date.

but my advice will be to use the API REST developed by Atlassian below

https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-projects/

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events