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

How to create a page in my Confluence Space using REST API in Python?

Jagruthi k Aug 05, 2015
 

2 answers

0 votes
Jaime Silveira Atlassian Team Aug 05, 2015

Hi, Jagruthi.

I don't know exactly how you handle REST API calls in Python, but you should use the POST function /rest/api/content.


This documentation will probably be helpful:

https://docs.atlassian.com/atlassian-confluence/REST/latest/#d3e568

Kind regards,
Jaime Kirch da Silveira
Atlassian Cloud Support

0 votes
Rafael Sperafico Atlassian Team Aug 05, 2015

Hello Jagruthi,

Thank you for your question.

Please, find below a code sample on how to create a space as per REST API documentation:

# =========
# create space
# =========
import requests
import json

# [CONFLUENCE-BASE-URL], i.e.: http(s)://confluence
# [SPACE-KEY], i.e.: ds (stands for Demonstration Space)
# [SPACE-TITLE], i.e.: Demonstration Space
url = '[CONFLUENCE-BASE-URL]/rest/api/content/'
data = {"key":"[SPACE-KEY]","name":"[SPACE-TITLE]","description":{"plain":{"value":"This is an example space","representation":"plain"}}}
headers = {'Content-Type': 'application/json'}

# create page
# [USERNAME], i.e.: admin
# [PASSWORD], i.e.: admin
r = requests.post(url, data=json.dumps(data), headers=headers, auth=('admin', 'admin'))
print(r.status_code)
print(r.text)

If you find this answer useful, I would kindly ask you to accept it so the same will be visible to others who might be facing the same issue you have inquired.

Thank you for your understanding.

Kind regards,
Rafael P. Sperafico
Atlassian Support

 

Tong Wu Nov 11, 2015

I receive a 401 error. How come?

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Posted in Statuspage

⭐️Would you recommend Statuspage? Leave a (honest!) review. ⭐️

Hi Community friends, We're working on sourcing more reviews on Capterra – a popular software review site –  to help teams like yours make more informed decisions when choosing an inc...

66 views 3 5
Join discussion

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