Afternoon All!
I’m writing a couple of bash scripts for my client and one of these scripts is to upload markdown files from various git repos in the CI pipeline.
Now i can quite happely upload the document using curl
msg="{“title”: “”,“type”: “page”,“space”: {“key”: “SPACEKEY”},“ancestors”: [{“id”: “$1”}], “version”: { “number”: “0” }, “body”: {“storage”: {“value”: “MARKDOWN GOES HERE”,“representation”: “wiki”}}}"
curl -s -X POST --header “$authHeader” --header “Accept: application/json” --header “Content-Type: application/json” --data “$msg” --url “$1”
Now the page is created on the server and the content is indeed set whatever i pass into storage.value. but the rendering is not correct. I found a few posts that said to use the “wiki” representation but that didn’t make a difference.
Any ideas?
Hi @CedricBrasey , welcome to the Community!
Can you please let us know what is not correct about the rendering? Any snapshots of observed rendering would be helpful for us too.
Thanks
szn
June 7, 2021, 8:40am
3
This is not exactly what you asked for, but I believe it can be helpful:
This Python project converts MD into HTML first, and then uploads it into Confluence.
Hi,
Another option would be to save the content into the macro body of the macro provided by this Marketplace app:
Then you wouldn’t have to worry about conversion.
Full disclosure: I belong to the organization that wrote this Marketplace app.
Is this possible using the API somehow? I really want to use the Render Markdown plugin for automatic uploading and rendering of markdown files
Yes, you can use the standard Confluence API features for creating/updating a page:
https://developer.atlassian.com/cloud/confluence/rest-api-examples/#manipulating-content
and simply make sure that the storage format looks like this:
<ac:structured-macro ac:name="markdown"><ac:plain-text-body><![CDATA[
## markdown goes here
]]></ac:plain-text-body></ac:structured-macro>
You would need to have the Render Markdown macro installed for this to work.
2 Likes