Hi,
How to get Confluence Space content with image links with using REST API.
When I use request https://confluence.link/rest/api/content/{ID}?expand=body.storage
Image link becoming like this:
<p><ac:image><ri:attachment ri:filename=\"image.jpg\" /></ac:image></p>
*** How to get it like this: <img src="http://example.com/image.jpg">
Community moderators have prevented the ability to post new answers.
Hei, use the expand=body.view query parameter. Like this:
https://confluence.link/rest/api/content/{ID}?expand=body.view
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@MichałS I am trying to upload pictures from url but it is not showing on wiki, here are is the script:
$user = "XXXX"
$pass = 'XXXX'
$pair = "${user}:${pass}"
$bytes = [System.Text.Encoding]::ASCII.GetBytes($pair)
$base64 = [System.Convert]::ToBase64String($bytes)
$basicAuthValue = "Basic $base64"
$headers = @{ Authorization = $basicAuthValue }
#ID of parant page (If you dont wont a parant just remove this and the ancestors part of the post request)
$parantId = "51647589"
$key = 'CORPSYS' # The key to the Space
$title = 'Test page 4'
$pageContent='
<h1>This is a test</h1>
<p>This site is created from Powershell</p>
<img src='http://XX-XXX-001:81/Images/XXX/TechAnniver.jpg'/>
'
#Generate post request as PowerShell objects
$post = @{
type = 'page'
"ancestors" = @(
@{"id" = $parantId}
)
title = $title
space = @{ key = $key}
body = @{
storage = @{
value = $pageContent
representation = 'storage'
}
}
}
#Convert post to json
$json = ConvertTo-Json $post
Write-Output $json
#Post request to Confluence
try {
Invoke-RestMethod -Uri 'https://wiki.cvent.com/rest/api/content/' -Method POST -ContentType "application/json" -Body $json -Headers $headers
} catch {$_.Exception.Response }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@MichałS I am trying to create a page on wiki through power shell script using API. I tried to display image through html but it is not working
$user = "XXX"
$pass = 'XXXX
$pair = "${user}:${pass}"
$bytes = [System.Text.Encoding]::ASCII.GetBytes($pair)
$base64 = [System.Convert]::ToBase64String($bytes)
$basicAuthValue = "Basic $base64"
$headers = @{ Authorization = $basicAuthValue }
#ID of parant page (If you dont wont a parant just remove this and the ancestors part of the post request)
$parantId = "51647589"
$key = 'CORPSYS' # The key to the Space
$title = 'Test page 4'
$pageContent='
<h1>This is a test</h1>
<p>This site is created from Powershell</p>
<img src='http://XXX01-XX-001:81/Images/XX/TechAnniver.jpg'/>
'
#Generate post request as PowerShell objects
$post = @{
type = 'page'
"ancestors" = @(
@{"id" = $parantId}
)
title = $title
space = @{ key = $key}
body = @{
storage = @{
value = $pageContent
representation = 'storage'
}
}
}
#Convert post to json
$json = ConvertTo-Json $post
Write-Output $json
#Post request to Confluence
try {
Invoke-RestMethod -Uri 'https://wiki.cvent.com/rest/api/content/' -Method POST -ContentType "application/json" -Body $json -Headers $headers
} catch {$_.Exception.Response }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.