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

How to get Confluence Content image links by Confluence REST API?

Zubaidullou November 30, 2014

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">

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
MichałS
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.
November 30, 2014

Hei, use the expand=body.view query parameter. Like this:

https://confluence.link/rest/api/content/{ID}?expand=body.view

Zubaidullou December 1, 2014

thanks

Raghwendra Singh July 17, 2018

@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 }

Raghwendra Singh July 17, 2018

@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 }

TAGS
AUG Leaders

Atlassian Community Events