How can I create a new page to confluence with Python
Question: 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?


Answer: I dont know Python, but can do this with a REST call:

    
    
    echo '{"type":"page","ancestors":[{"type":"page","id":'$CONFLUENCE_PARENT_PAGE'}],"title":"'$PAGE_NAME'","space":{"key":"'$CONFLUENCE_SPACE'"},"body":{"storage":{"value":"'$CONTENT'","representation":"storage"}}}' > body.json
    
    curl --globoff --insecure --silent -u ${CONFLUENCE_USER}:${CONFLUENCE_PASSWORD} -X POST -H 'Content-Type: application/json' --data @body.json $CONFLUENCE_REST_API_URL
    

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.

