You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
I am trying to get confluence to integrate with Azure for documentation purposes. I get the error below.
`Invoke-RestMethod : HTTP Status 401 – Unauthorizedbody {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line
{height:1px;background-color:#525D76;border:none;}HTTP Status 401 – UnauthorizedType Status ReportMessage Basic Authentication Failure - Reason : com.atlassian.crowd.exception.FailedAuthenticationException: com.atlassian.crowd.exception.InvalidAuthenticationException:
Invalid credentialsDescription The request has not been applied because it lacks valid authentication credentials for the target resource.Apache Tomcat/9.0.71`
It suggests a permission issue i.e the 401 error code. Here is what I have done.
$SpaceKey = my-space"
$Page = ""
$Content = "<h1>This is a test</h1>"
$baseUri = 'https://xxxxxx.atlassian.net/wiki/'
$apikey = (az keyvault secret show --name 'apikey' --vault-name 'my-kv' | ConvertFrom-Json).value
$user = (az keyvault secret show --name 'username' --vault-name 'my-kv' | ConvertFrom-Json).value
write-output $apikey
write-output $user
$credential = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($User + ":" + $apikey))
function Get-RestHeaders {
return @{ 'Authorization' = 'Basic ' + $credential }
}
$headers = Get-RestHeaders
write-output $headers
The code above returns the headers
`Name Value
Authorization Basic dG95aW53ZWJAeWFob28uY28udWs6QVRDVFQzeEZmR04wNxxxxxxxxx`
However this section of the code is what is proving problematic.
$title = 'Documentation'
$headers = Get-RestHeaders
$uri = $baseUri + "rest/api/content?title=$($title.Trim() -replace " ", "+")&spaceKey=$SpaceKey"
$response = Invoke-RestMethod -Uri $uri -Method 'GET' -Headers $headers
`$response = Invoke-RestMethod -Uri $uri -Method 'GET' -Headers $heade CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
No page found matching Azure Resources - expected URL: https://xxxx.atlassian.net/wiki/rest/api/content?title=Azure+Resources&spaceKey=my-key`