How can I create a new page to confluence with Python

前端 未结 3 1987
没有蜡笔的小新
没有蜡笔的小新 2021-01-06 09:12

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 tot

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-06 09:48

    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.

提交回复
热议问题