Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

how to attach multiple images and files to create page in confluence rest api

Vidya Shevale October 17, 2018

I am writing rest api in confluence  to create page

and also want to attach images  in it

but image is not showing in page

my php curl is as below

public function create_content(){
$qbody = file_get_contents("php://input");
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "http://localhost:8090/rest/api/content/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $qbody);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_USERPWD, "admin" . ":" . "Abc@1234");

$headers = array();
$headers[] = "Content-Type: application/json";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close ($ch);
print_r($result);
}

 

and sending request in raw 

i am sending image using base64 format and my html tags also not working

1 answer

0 votes
Thomas Deiler
Community Champion
October 17, 2018

Dear @Vidya Shevale,

afaik you cannot attach files/images to a page that does not exist or in other words, first create a page and then attach the files.

And you do not need to send the files base64 encoded - this will do curl for you.

Hope that helps. If not, please give me more details of what you exactly do.

So long

Thomas

antony terrence
Contributor
May 30, 2021

@Thomas Deiler  The fact that you are creating a new page, shouldn't it allow you to upload attachments with along with the new page data? Won't it be much better than having to make two calls to complete a page creation? Images are essentially page data,  For the image macro to work, the attachments should be present. Until the attachments are uploaded, the new page is incomplete. So Atlassian should have allowed users to upload attachments along with the page data. But it's unfortunate we have to do two calls to complete a page.

Thomas Deiler
Community Champion
June 7, 2021

Dear @antony terrence ,

you are right. Please open a suggestion at https://jira.atlassian.com for your requested feature.

So long

Thomas

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events