Create a Page Confluence REST API

With the XML-RPC/SOAP api deprecated, I want to consume the Confluence REST API.

I want to create a new page before populating it with some content. I managed to get get an existing page and edit it.
This functionality will be a part of a jira-plugin later on.

Cheers

2 Likes

You can create a page with the content endpoint. As an example, here’s some Bash using HTTPie to accomplish it:

#!/usr/bin/env bash
PAYLOAD=$(cat <<EOF
{
    "title": "$(date +%s)",
    "type": "page",
    "space": {
        "key": "${SPACEKEY}"
    },
    "body": {
        "wiki": {
            "value": "h1. Hello world!",
            "representation": "wiki"
        }
    }
}
EOF
)

echo "${PAYLOAD}" | http -a ${CONFLUENCE_USERNAME}:${CONFLUENCE_PASSWORD} \
    POST ${CONFLUENCE_BASE_URL}/rest/api/content
2 Likes