Unable to fetch Confluence data using atlassian python wrapper

Rajani Gutta
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!
December 13, 2020

Hi Team,

 

I am using below python code to get some confluence page data , but i am getting 401 CLient error .

Please suggest.

from atlassian import Confluence

confluence = Confluence(
url='https://myconfluence.domain.com',
username='companyemailid',
password='APItokengenerated')

# If you know Space and Title
content1 = confluence.get_page_by_title(space="DOSNI", title="Airflow")

print(content1)



Error

requests.exceptions.HTTPError: 401 Client Error: for url: https://url/rest/api/content?start=0&limit=1&spaceKey=DOSNI&title=Airflow

 

1 answer

1 accepted

0 votes
Answer accepted
Prince Nyeche
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 14, 2020

Hi @Rajani Gutta 

Welcome to Community! What's your hosted platform? are you using Cloud or Self-hosted. If it's the latter you might want to specify the direct URL where your confluence is installed and stick to username and password. Otherwise if it's Cloud use 

https://myconfluence.atlassian.net/wiki

Then  generate your API token and use with your email Address.

Rajani Gutta
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!
December 14, 2020

Hi @Prince Nyeche ,

Thanks a lot for the quick reply, I dont have atlassian.net in the url , so I think confluence is hosted on prem Dataserver.

I started initially by trying username as password in atlassian module like below .

from atlassian import Confluence

confluence = Confluence(
url='https://myconfluence.companyname.com',
username='myid',
password='password')


But it also threw 401 Error.

Just to add, we have ping federated integrated as two factor authentication .
So after first authentication with username and password, we need to provide ping id also which we received as SMS to login to confluence .

Can you please let me know in such cases , how can i fetch data using REST API , or if there is any other way for fetching data .

'

Prince Nyeche
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 14, 2020

That would be a problem then, 2FA will definitely block the authentication from working. Server Products doesn't use an API key which bypasses 2FA features. Alternatively, I believe this framework supports OAuth. Something you could configure on your Server if you possess the access.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events