I cant replace layoutSections of page via API. Error: errorType":“INVALID_JSON_VALUE”,“message”:"Unable to set value for layoutSections > dnd_area > params on page from JSON
Code:
test = array(“layoutSections” => $response_array[‘layoutSections’]);
$datas = json_encode($test , JSON_UNESCAPED_SLASHES);
// The URL for the PATCH request
$url = ‘https://api.hubapi.com/cms/v3/pages/site-pages/’ . $page_id;
// Initialize cURL session
$ch = curl_init($url);
// Set cURL options
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, ‘PATCH’);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Authorization: Bearer ' . $bearer\_token,
'Content-Type: application/json'
));
curl_setopt($ch, CURLOPT_POSTFIELDS, $datas);
// Execute cURL session and fetch response
$response = curl_exec($ch);
// Check for errors
if (curl_errno($ch)) {
echo 'Error:' . curl\_error($ch);
} else {
// Print response for debugging
echo $response;
}
// Close cURL session
curl_close($ch);