You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
I'm working on a PowerShell script that would allow me to upload a local Markdown file from a path, and create a Confluence sub-page under a parent page and display the file's contents as Markdown.
So far I'm able to create the sub-page under whatever parent or space I like, however, the Markdown isn't displaying as Markdown, just raw text.
I tried going over the REST API docs and tried using both representation types: storage (errors out) and wiki (works but doesn't shows as raw text).
Any ideas on what I'm doing wrong? Been stuck a while on this one...
Here's how the user inputs parameters for the script:
New-MarkdownSubPage -ConfluenceUrl "https://confluence.domain.corp" -SpaceKey "SPACE1" -PageTitle "Parent_Page" -FilePath "C:\Temp\markdown.md"
And here's the relevant bits of the script:
$parentPageUri = "$ConfluenceUrl/rest/api/content?spaceKey=$SpaceKey&title=$PageTitle"
$parentPage = Invoke-ConfluenceAPI -Uri $parentPageUri -Method "GET"
$parentPageId = $parentPage.results.id
$fileContent = Get-Content -Path $FilePath -Raw
$fileName = (Get-Item -Path $FilePath).Name
$pageData = @{
type = "page"
title = $fileName
space = @{ key = $SpaceKey }
ancestors = @(@{ id = $parentPageId })
body = @{
storage = @{
value = $fileContent
representation = "wiki"
}
}
} | ConvertTo-Json -Depth 100
$createPageUri = "$ConfluenceUrl/rest/api/content"
$createdPage = Invoke-ConfluenceAPI -Uri $createPageUri -Method "POST" -Body $pageData
You need to convert the Markdown to Confluence storage Format. Maybe try an addon https://marketplace.atlassian.com/apps/1211438/markdown-html-plantuml-latex-diagrams-open-api-mermaid
Maybe a Library for this exists?
Regards Benno
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.