Hi, I’ve been struggling to make a PATCH curl request through PHP but it’s not working. I’ve tried various combinations and searched the forums for examples and ideas but I keep getting
{“errors”:{“error”:“JSON: Syntax error”}}
Here’s a short version of my code :
$data["dcterms:format"] = array(
array(
"type" => "customvocab:8",
"property_id" => 9,
"property_label" => "Format",
"is_public" => 1,
"@value" => $technique_el,
"@language" => "el"
),
array(
"type" => "customvocab:22",
"property_id" => 9,
"property_label" => "Format",
"is_public" => 1,
"@value" => $technique_en,
"@language" => "en"
)
);
$JSONdata = "[".json_encode($data)."]";
$ch = curl_init();
$headers = array('Content-type: application/json');
curl_setopt_array($ch, array(
CURLOPT_URL => 'https://dam.momus.gr/api/items/1098/?key_identity=xxx&key_credential=xxx',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'PATCH',
CURLOPT_POSTFIELDS => $JSONdata,
CURLOPT_HTTPHEADER => $headers,
));
$response = curl_exec($ch);
echo '<pre>'; print_r($response); echo '</pre>';
curl_close($ch);
I can’t seem to find where the problem is. I welcome any ideas…