I am running PHP script in tomcat to update page content in confluence REST API
$requestStorage = array(
"id" => $parentID,
"type" => "page",
"title" => $title,
"space" => array(
"key" => $workspaceKey
),
"body" => array(
"storage" => array(
"value" => "".$contentName."",
"representation" => "storage"
),
),
"version" => array(
"number"=> $version
),
);
$qbodyChild = json_encode($requestStorage);
$CURLOPT_URL= $GLOBALS['host'] ."rest/api/content/".$parentID ;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $CURLOPT_URL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $qbodyChild);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$headers = array();
$headers[] = "Accept : application/json";
$headers[] = "Content-Type: application/json";
$headers[] = "Authorization: Basic ".base64_encode($GLOBALS['username'].":".$GLOBALS['password']);
$headers[] = "Cache-Control: no-cache";
$headers[] = "Content-length:".strlen($requestStorage);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch); die;
}
curl_close ($ch);die;
I also tried adding "ancestors" => array(
array(
"id" => $parentID
)
)
also work
curl -u admin:Abc@1234 -X PUT -H 'Content-Type: application/json' --data '{"id":"983786","type":"page","title":"title","body":{"storage":{"value":"<p>testNum</p>","representation":"storage"}},"version":{"number":2}}' http://localhost:8090/rest/api/content/983786
please help me ASAP
TIA