Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,556,741
Community Members
 
Community Events
184
Community Groups

i am writting a powershell script in bamboo in order to post html data to the confluence child page

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 }

1 answer

Hi there - 

Doing this type of stuff programmatically can be cumbersome.  When I did something similar a few years ago, I used postman to get my request proper FIRST, then translated that over to powershell.  This helps AH LOHT!

Also, since you are running as an unattended script, you will need the invoke-webrequest -usebasicparsing *otherwise it will attempt to load the profile in the request, which likely wont fly for the user executing bamboo.

Good luck

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events