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,639,531
Community Members
 
Community Events
196
Community Groups

Connecting to Confluence with API key and ConfluencePS

I am trying to connect to my company's confluence space by using the ConfluencePS but I cannot seem to authenticate my account.

I have created an PAT on both Atlassian.net and directly on the Data Center that Confluence is hosted on. Neither seem to work.

The URI is set up in the format "https://confl.CompanyName.com".

The code I am using to attempt to connect is shown below.


Import-Module ConfluencePS
$Username = 'first.last@mycompany.com'
$Password = 'full_token_string' | ConvertTo-SecureString -AsPlainText -Force

$Credentials = New-Object System.Management.Automation.PsCredential($Username,$Password)

Set-ConfluenceInfo -BaseURI 'https://confl.CompanyName.com' -Credential $Credentials

Get-ConfluenceSpace  -SpaceKey '####'


When this runs, I receive back a 401: UNAUTHORIZED error

I've also tried for the password, the token name, the Atlassian token, the password to my account, the token on the data center. I can't seem to find what is expecting.

 

Can ConfluencePS work on Data Center based Confluence pages? How can I go about using this?

 

1 answer

1 vote
Andrii Maliuta
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Feb 19, 2023

@Brendan ,

You can try first if Authentication works using other method like CURL or HTTPIE or Postman, etc. just to be sure that the user/password and the encoded password work. For authentication you can use headers as { "Authentication": "Basic {base64encodedPassword}"}.

 

Powershell simple GET to check auth:

$cred = Get-Credential
Invoke-WebRequest -Uri 'https://confl.CompanyName.com/rest/api/content' -Credential $cred
Invoke-WebRequest -Method Get -Uri 'https://confl.CompanyName.com/rest/api/content' -Authentication Basic 

 

other clis:

https -a user:pass https://confl.CompanyName.com/rest/api/content

curl -X user:pass https://confl.CompanyName.com/rest/api/content

https -a user:pass https://confl.CompanyName.com/rest/api/content

Thanks for the answer, it seems like I am able to reach the API when using the Invoke-WebRequest or curl methods but when I try to do anything with the ConfluencePS module, I still am seeing the 401 error. Image attached for reference.

ConfluencePS_no_work.png

Andrii Maliuta
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Feb 22, 2023

@Brendan ,

It needs more deep debugging of what is the cause in code. Maybe it would be better to contact the team of ConfuencePS:

https://atlassianps.org/module/ConfluencePS/

https://atlassianps.org/slack

Thanks for all the help. I have posted within there. If I find an answer I will be sure to post it here.

Like Andrii Maliuta likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events