Trying to find a solution of importing a large amount of data from an excel source, and have it populate a confluence page with specific formatting already created. As we are quite used to creating markup files for other portions of the business, I thought one way to do this is to read in a valid XML/XHTML file that I create using a script and have that generate a confluence page (assuming the xml file in question meets the formatting criteria for confluence pages)
I have been able to view the storage format used for confluence pages, so I feel I can get a pretty good idea of how to generate a valid markup file for a page.
Question - is it possible to create a page strictly through importing the markup file?
I will check out these solutions! Thank you for the response, this helps!
With https://confluence.atlassian.com/doc/confluence-storage-format-790796544.html it should be possible with REST API:
# https://docs.atlassian.com/ConfluenceServer/rest/7.20.0/#content-createContent
Although I must say this documentation is getting me dizzy.
I don't have any "create" example on my hands, but I wrote a script a few months back to update a specific page weekly, so I reckon this might be similar to your case.
info "Updating Confluence page .." |tee -a $DEBUGLOG
# I guess you can ignore this trash here, but I'm just leaving it in for reference..
nextVersion=$(expr $(($(cat $tmpDir/page.currentVersion) + 1))) pageTitle="$(cat $tmpDir/page.title)"
echo '{"id":"'"${CONFLUENCE_PAGEID}"'", "title": "'"$pageTitle"'", "version": {"number": '"$nextVersion"'}, "type": "page", "body":{"storage":{"value":"'"$(cat $tmpDir/page.body.storage-updated | sed 's#"#\\"#g')"'", "representation":"storage"}}}' > $tmpDir/put-data.json URL="${CONFLUENCE_INSTANCE}${RESTPATH_CONTENT}${CONFLUENCE_PAGEID}"
debug "URL: $URL" >> $DEBUGLOG debug "pageTitle: $pageTitle" >> $DEBUGLOG debug "nextVersion: $nextVersion" >> $DEBUGLOG
cat $tmpDir/put-data.json >> $DEBUGLOG
# And this is the PUT for update
curl -X PUT \ -b "$apiToken_Confluence" \ -s -S \ -H 'Content-Type: application/json' \ -d @$tmpDir/put-data.json \ --url "$URL" \ -o $tmpDir/put-response
And as you see from this, I did use the storage format. First I got the current page via GET - and I parsed the json response with python to get the title, body, and current version. Then I modified the body (so the body is in $tmpDir/page.body.storage-updated), and with that I then stitched the json back together as $tmpDir/put-data.json, and then I sent it back with PUT as an update.
Can't paste the whole bash script since it's technically proprietary and has a few "specific" data in it, but this snippet is generic enough to be pasted publicly.
Apart from REST, Confluence does have one option of importing files from the disk, and it should support storage format as well:
# https://confluence.atlassian.com/conf59/import-a-text-file-792499637.html
So if you prepped the pages and put them in a directory of your Confluence's choosing (it shows the directory in Space administration -> Content Tools -> Import), it should also work, and it should replace an existing page if the page name is the same, although I have no experience with this particular import page.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.