Currently the rest API can get data from within a page, however we would like to be able to get data from within a space using space-id.
A workaround has been developed$ConfluenceURLAPI = "https://confluence.company.com/rest/api/content"
$ConfluenceURLAPI = "https://confluence.company.com/rest/api/content"
$ConfluenceURLAPIScaf = "https://confluence.company.com/rest/scaffolding/1.0/api/form"
$nameOfMySpace = "SpaceY"
$headNode= "1083508107"
$cred = Get-Credential
$Headers = @{'Authorization' = "Basic "+[System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes(($cred.UserName+":"+[System.Runtime.InteropServices.marshal]::PtrToStringAuto([System.Runtime.InteropServices.marshal]::SecureStringToBSTR($cred.Password)) )))
'X-Atlassian-Token' = 'nocheck'
}
$filter = "search?cql=(space=($($nameOfMySpace)%20and%20ancestor=$($headNode))"
$pageUriPath = "$($ConfluenceURLAPI)/$($filter)"
$pageContent = Invoke-WebRequest -Method GET -Headers $Headers -Uri $pageUriPath | ConvertFrom-Json
if(!([String]::IsNullOrEmpty($pageContent))){
$i=0
$data = @{}
foreach ( $page in $pageContent.results ){
$filter = "$($page.id)"
$pageUriPath = "$($ConfluenceURLAPIScaf)/$($filter)"
$pageContent2 = Invoke-WebRequest -Method GET -Headers $Headers -Uri $pageUriPath
$data[$i] = [System.Text.Encoding]::UTF8.GetString([System.Text.Encoding]::GetEncoding("ISO-8859-1").GetBytes($pageContent2.Content)) | ConvertFrom-Json
#FIX :bug encoding https://social.technet.microsoft.com/Forums/en-US/cbf40856-9157-42ae-8127-0328b4664405/cant-show-content-of-invokewebrequest-in-unicode?forum=winserverpowershell
$i++
else{
Write-Host "TODO: add a notification to alert smbd to check what is broken and who to contact"
$object = [PSCustomObject]$data
$object | ConvertTo-Json | Out-File -FilePath "C:\users\userName\Desktop\file.json" -Encoding unicode
You won't be notified about changes to this idea.
A workaround has been developed
$ConfluenceURLAPI = "https://confluence.company.com/rest/api/content"
$ConfluenceURLAPIScaf = "https://confluence.company.com/rest/scaffolding/1.0/api/form"
$nameOfMySpace = "SpaceY"
$headNode= "1083508107"
$cred = Get-Credential
$Headers = @{'Authorization' = "Basic "+[System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes(($cred.UserName+":"+[System.Runtime.InteropServices.marshal]::PtrToStringAuto([System.Runtime.InteropServices.marshal]::SecureStringToBSTR($cred.Password)) )))
'X-Atlassian-Token' = 'nocheck'
}
$filter = "search?cql=(space=($($nameOfMySpace)%20and%20ancestor=$($headNode))"
$pageUriPath = "$($ConfluenceURLAPI)/$($filter)"
$pageContent = Invoke-WebRequest -Method GET -Headers $Headers -Uri $pageUriPath | ConvertFrom-Json
if(!([String]::IsNullOrEmpty($pageContent))){
$i=0
$data = @{}
foreach ( $page in $pageContent.results ){
$filter = "$($page.id)"
$pageUriPath = "$($ConfluenceURLAPIScaf)/$($filter)"
$pageContent2 = Invoke-WebRequest -Method GET -Headers $Headers -Uri $pageUriPath
$data[$i] = [System.Text.Encoding]::UTF8.GetString([System.Text.Encoding]::GetEncoding("ISO-8859-1").GetBytes($pageContent2.Content)) | ConvertFrom-Json
#FIX :bug encoding https://social.technet.microsoft.com/Forums/en-US/cbf40856-9157-42ae-8127-0328b4664405/cant-show-content-of-invokewebrequest-in-unicode?forum=winserverpowershell
$i++
}
}
else{
Write-Host "TODO: add a notification to alert smbd to check what is broken and who to contact"
}
$object = [PSCustomObject]$data
$object | ConvertTo-Json | Out-File -FilePath "C:\users\userName\Desktop\file.json" -Encoding unicode
Attachments Open full size