i am writting a powershell script in bamboo in order to post html data to the confluence child page.
The script is passing in bamboo, but i am not able to see data in confluence. Please help.
Script:
#variables
$ConfluenceURL = "https://network_name.com/rest/api/content/"
$username="${bamboo.Username}"
$password="${bamboo.Password}"
#Where the page gets created
$spaceKey = 'space_name' #Space Key
$parentId = "Parent_id" #ID of parent page
$pageTitle = 'pager1'
#Content
$pageContent = 'welcome'
#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
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username,$password)))
$headers = @{Authorization=("Basic {0}" -f $base64AuthInfo)}
$ContentType = "application/json";
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true} ;
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
#Post request to Confluence
try {
Invoke-WebRequest -Uri $ConfluenceURL -Method POST -ContentType "application/json" -Body $post Headers $headers
} catch {$_.Exception.Response }