Update page using API with markdown content

dustin_butler
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 17, 2024

I'm updating a page with markdown content via the the API.  The update works but the page in Confluence is showing the raw markdown text instead of formatting it.

Here is the API call I'm using to update the page

curl -o output.html -0 -v -X PUT https://inhabitiq.atlassian.net/wiki/api/v2/pages/${ATLASSIAN_PAGE_ID} \
-u "${ATLASSIAN_USER}:${ATLASSIAN_API_TOKEN}" \
-H "Expect:" \
-H 'Content-Type: application/json; charset=utf-8' \
--http1.1 \
--data-binary @- << EOF
{
"id": "${ATLASSIAN_PAGE_ID}",
"status": "current",
"title": "API Documentation",
"body": {
"representation": "storage",
"value": ${NEW_CONTENT}
},
"version": {
"number": 25,
"message": "Updated API documentation"
}
}
EOF

2 answers

1 accepted

0 votes
Answer accepted
David Bakkers
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 17, 2024

Hello @dustin_butler 

The representation format for markdown is 'wiki' ('storage' is HTML and 'atlas_doc_format' is ADF)

0 votes
dustin_butler
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 20, 2024

Thanks for the reply.  After looking into this some more found that $NEW_CONTENT was being converted from markdown into HTML with pandoc.

 

NEW_CONTENT=$(pandoc -f markdown $(pwd)/docs/docs.md | jq -Rs .);

Was throwing 500 when trying to use wiki representation but all working now. 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events