Hi,
This is my whole scenario: Export OneNote pages via powershell, then upload them via REST API into Confluence.
The export is fine and I´m getting functional html-pages. But how do I upload them into confluence without external solutions like plugins or server-addons?
My current script (creating pages is working with e.g. <p> test content </p>):
#Variables
$Credentials = GET-Credential
$ConfluenceURL = "https://<domain>.com/rest/api/content/"
$pageContentHTML = GET-Content C:\<directory>\TestFile.htm
#Where the page gets created
$spaceKey = '<key>' #Space Key
$parentId = "<parentID>" #ID of parent page
$pageTitle = 'A first test page'
#Content
$pageContent = $pageContentHTML
#Generate post request as PowerShell objects
$post = @{
type = 'page'
"ancestors" = @(
@{"id" = $parentId}
)
title = $pageTitle
space = @{ key = $spaceKey}
body = @{
storage = @{
value = '$pageContent'
representation = 'storage'
}
}
}
#Header for authentification
$header = @{"Authorization" = "Basic "+[System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes(($Credentials.UserName+":"+[System.Runtime.InteropServices.marshal]::PtrToStringAuto([System.Runtime.InteropServices.marshal]::SecureStringToBSTR($Credentials.Password)) )))}
#Convert post to json
$json = ConvertTo-Json $post
#Post request to Confluence
try {
Invoke-RestMethod -Uri $ConfluenceURL -Method POST -ContentType "application/json" -Body $json -Headers $header
} catch {$_.Exception.Response }
Thank you
so long
Jan