The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

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

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

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
Answer accepted
Prince Nyeche - ELFAPP
Atlassian Partner
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 - ELFAPP ,

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 - ELFAPP
Atlassian Partner
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.

TAGS
AUG Leaders

Atlassian Community Events