I am trying to create a new page into confluence using Python's xmlrpclib
. I already know how to update content of an existing page, but how can I create a totally new page?
I have used following script to update content:
import xmlrpclib
CONFLUENCE_URL='https://wiki.*ownURL*/rpc/xmlrpc'
def update_confluence(user, pwd, pageid, newcontent):
client = xmlrpclib.Server(CONFLUENCE_URL,verbose=0)
authToken=client.confluence2.login(user,pwd)
page = client.confluence2.getPage(authToken, pageid)
page['content'] = newcontent
cient.confluence2.storePage(authToken, page)
client.confluence2.logout(authToken)
and that works well when updating content. But problem is that somehow I need to resolve pageID
when creating a new page and I have no idea how to do that.
Are there any other ways to create new page?
I dont know Python, but can do this with a REST call:
The confluence rest api url looks something like this: https://confluence.yourdomain.com/rest/api/content/
Basically the answer to your question is you need to send the parent page as an ancestor when creating a brand new page.
You can create pages using the Confluence REST API: https://docs.atlassian.com/atlassian-confluence/REST/latest-server/
Here is an example that works in Python3. You'll need to know the parent page id.
Answer of "J. Antunes" is correct, but it took a long time for me to find the APIs, pageIds etc. This answer will give you a step by step guide on how to achieve this with API Tokens.
Step 1: Generate API Token in Confluence.
In the confluence page, go to Settings and click on password. Click on "Create and manage API tokens" and get the token. {TOKEN}
Step 2: Find the parent page you want to create a child page at
Go to get the parent page ID, and find the {Parent Page ID}
Step 3: Get the Space Key
On confluence, go to Space Settings, and find the Space Key mentioned.{SPACE KEY}
Step 4: Now get started with the code