Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

0 votes

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
Community showcase
Published in Bamboo

Bamboo Data Center - Early Access Program

G’day Bamboo customers, The wait is almost over! We are in the final stages of work on the first release of Bamboo Data Center, our self-managed enterprise offering of Bamboo. This Data Center offe...

1,008 views 0 16
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you