Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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

Create a page in Confluence - Python API Edited


I am trying to create a page in Confluence with the python API. I tried it like written here:

This is my code:

from atlassian import Confluence
import requests
import json
from requests.auth import HTTPBasicAuth

confluence = Confluence(

page_title = 'My New Page'
page_html = '<p>This page was created with Python!</p>'

parent_page_id = ...
space_key = '...'

auth_token = ".." 
basic_auth = HTTPBasicAuth('mail', auth_token)


url = 'https://.../rest/api/content/'

# Request Headers
headers = {
'Content-Type': 'application/json;charset=iso-8859-1',

# Request body
data = {
'type': 'page',
'title': page_title,
'ancestors': [{'id':parent_page_id}],
'space': {'key':space_key},
'body': {
'value': page_html,



r =, data=json.dumps(data), headers=headers, auth=basic_auth)

# Consider any status other than 2xx an error
if not r.status_code // 100 == 2:
print("Error: Unexpected response {}".format(r))
print('Page Created!')

except requests.exceptions.RequestException as e:

# A serious problem happened, like an SSLError or InvalidURL
print("Error: {}".format(e))


my first question: where do I get the token? With this token it doesn't work. 

second the output is: 

Unexpected response <Response [401]>

I think the authentication doesn't work. But i dont know how to authenticate....  


If I try this: 

oauth_dict = {
    'access_token': 'access_token',
    'access_token_secret': 'access_token_secret',
    'consumer_key': 'consumer_key',
    'key_cert': 'key_cert'}

Where do i get the secret token, the consumer key and the key_cert?? 

pls help.. 

1 answer

1 accepted

0 votes
Answer accepted
Dario B Atlassian Team Jun 09, 2021

Hello @Marlene Pirker ,

Please notice that the Atlassian Python API is neither built nor supported by Atlassian and there are chances this is a bug with this 3rd party API.

For the rest, as mentioned in the Basic auth for REST APIs documentation page, you need to use the same email address you use to log-into Confluence Cloud as the username and an  API token (that you indeed generate from as the password.

Please review the below links for further details on this:


I hope this helps.



Thank you so much for your answer. I already managed to connect with Confluence Cloud using the API and a token. I am not able to connect to the server but that seems to be a permission problem from our side.

Dario B Atlassian Team Jun 10, 2021

@Marlene Pirker You are very welcome and I am happy to know this helped :) 

Also, please notice that in order to authenticate REST API calls against Jira Server you need to use username and password instead of email address and api token.

I hope this helps. 

Suggest an answer

Log in or Sign up to answer

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