How do I display checkboxes correctly in the API?
Asked by Naruse Murai:

I made a request like this based on the [here](https://community.atlassian.com/t5/Confluence-questions/Markdown-checkbox-list/qaq-p/1698494) answer, but the checkbox is not displayed correctly in Confluence.

```
curl --request PUT \
  --url "https://$domain/wiki/api/v2/pages/$pageid" \
  --user "$user:$token" \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '{
    "id": "<page id>",
    "status": "current",
    "title": "Create Page from Confluence API",
    "body": {
      "representation": "storage",
      "value": "[] check1"
    },
    "version": {
      "number": 2,
      "message": "v2.0"
    }
}'
```

In confluence it looks like this.

*** ** * ** ***

![????????? 2024-04-08 11.29.12.png](/t5/image/serverpage/image-id/316863iC650E428168360D2/image-dimensions/342x113?v=v2 "????????? 2024-04-08 11.29.12.png")

*** ** * ** ***

Is there a way to display it correctly?


Answers:
author: Kyle Long
body: Hi,  

- Confluence cloud has moved away from wiki markup (confluences version of markdown)

- Rest api does not support Markdown (the editor does)  

Internal storage of pages is in an xml storage format. Hence If you wish to use check boxes and other formatting use xml

<br />

E.g  
\[ \] checkmark box 1

\[ \] checkmark box 2

<br />

would look like In xml:

```
<ac:task-list>
??<ac:task>
????<ac:task-status>incomplete</ac:task-status>
????<ac:task-body>checkmark box 1</ac:task-body>
??</ac:task>
??<ac:task>
????<ac:task-status>incomplete</ac:task-status>
????<ac:task-body>checkmark box 2</ac:task-body>
??</ac:task>
</ac:task-list>
```

API request:

```
curl --request PUT \
?--url "https://$domain/wiki/api/v2/pages/$pageid" \
?--user "$user:$token" \
?--header 'Accept: application/json' \
?--header 'Content-Type: application/json' \
?--data '{
???"id": "<page ID>",
???"status": "current",
???"title": "Create Page from Confluence API",
???"body": {
?????"representation": "storage",
?????"value": "<ac:task-list><ac:task><ac:task-status>incomplete</ac:task-status><ac:task-body>checkmark box 1</ac:task-body></ac:task><ac:task><ac:task-status>incomplete</ac:task-status><ac:task-body>checkmark box 2</ac:task-body></ac:task></ac:task-list>"
???},
???"version": {
?????"number": 10,
?????"message": "v4.0"
???}
}'
```

![Screenshot 2024-04-09 at 8.53.51?AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/317099i528F378D3AE842F1/image-size/large?v=v2&px=999 "Screenshot 2024-04-09 at 8.53.51?AM.png")

comments: author: Naruse Murai
body: [@Kyle Long](/t5/user/viewprofilepage/user-id/5471005)

We confirmed that it works as expected with xml storage format. thank you :)

<br />

By the way, are there any tools available to convert GitHub Markdown to xml storage format?


author: Kyle Long
body: There doesn't seem to be a good way to convert markdown -\> XML(compatible with confluence).   
Points of note:  
- Confluence Rest api does not support markdown (you can input to the editor)

- Confluence stores data in and xml/xhtml like form

- Github markdown is an extension of pure markdown and can include some HTML  

For context, I attempted the vite [README.md](https://github.com/vitejs/vite/blob/main/README.md)

Approaches I tried:

1. Converting the file to html and manually editing
   1. Convert .md file to HTML with [pandoc](https://pandoc.org/MANUAL.html):  
      $\>pandoc -s -o output.html vite_markdown.md
   2. Trimmed all the /n and escaped all the quotes "  
      $\>tr -d '\\n' \< output.htm \| sed 's/\\"/\\\\"/g' \> output_formatted.html
   3. Manually removed incompatible HTML tags like:  
      \<br\> \<img\> \<code\>
   4. This kinda worked but it was a massive pain and if your markdown is complicated or you have many files this wouldn't work
2. Asking ChatGPT
   1. This works on simple markdown but anything complex like the above with included HTML it struggles to produce anything of value.
3. [Mark tool](https://github.com/kovetskiy/mark) --- a tool for syncing your markdown documentation with Atlassian Confluence pages.
   1. Note this is not an atlassian tool however it's the only tool that I could find that is recently updated that works.
   2. The tool can be used like this:  
      $\>mark -b $base_url -u $myemail -p $token -l $space -f vite_markdown.md
      1. Where:  
         base_url=https://\<your_site\>[.atlassian.net/wiki](http://.atlassian.net/wiki) myemail=\<your atlassian account email\>  
         token=\<your_apitoken\>  
         space=\<your space name\>  
         In the top of your markdown file also include the metadata headings:  
         \<!-- Space: \<your test space name\> --\>  
         \<!-- Title: \<title of the page you are updating\>--\>
   3. Use the --debug flag to help debug issuesThis should result in the tool converting the markdown and posting it to the specified confluence page  
      ![2024-04-11_16-34-26.png](https://community.atlassian.com/t5/image/serverpage/image-id/317645i11930F7E353CB9B5/image-size/large?v=v2&px=999 "2024-04-11_16-34-26.png")
   4. Caveats:
      1. If your .md uses a combination of html as well you may still need to trim the tags that will cause it to fail or use pandoc to only convert the HTML parts
         1. Cut the html parts and convert with pandoc  
            $\>pandoc html_part.html -f html -t markdown -s -o html_converted.md
         2. Recombine to the original file
         3. Add the metadata headers
         4. Run mark tool

Final thoughts if you only have a few simple files, try a combination of converting the file formats chatgpt and manually editing to get the job done. If you are dealing with many files and want to do it programmatically Mark tool could be a good option (I got the best results, with no manual editing). Note the image below is the process of cutting html converting and recombining with MD. It's not a perfect result and some image sizes are off but I'd say its about 92% accurate without any manual edits and if you edit the doc in confluence later you can fix some of the sizing and spacing.

![Screenshot 2024-04-11 at 5.05.08?PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/317644i113452AABD62738F/image-size/large?v=v2&px=999 "Screenshot 2024-04-11 at 5.05.08?PM.png")


author: Naruse Murai
body: Thank you for answering.  
I was trying to convert it programmatically, but Mark tool doesn't seem to support \`\<ac:task\*\>\`, so I'll try to implement it myself.


Tags: checkbox

cloud

confluence-cloud