Hi,
I am trying to delete a folder using the API, with a PHP cURL DELETE request but I never succeed.
Here are the two versions of the methods I am trying to use but none of them works. I always get a 404 Error.
public function deleteFolder($folderUid) {
$ch = curl_init('http://admin:password@172.0.0.1:3000/api/folders/');
$postFields = array(
'uid' => $grafanaFolderUId
);
curl_setopt_array($ch, array(
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json'
),
CURLOPT_POSTFIELDS => json_encode($postFields)
));
$response = curl_exec($ch);
// Decode the response
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
echo $httpCode;
}
public function deleteFolder($folderUid) {
$ch = curl_init('http://admin:password@172.0.0.1:3000/api/folders/' . $folderUid);
curl_setopt_array($ch, array(
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json'
),
));
$response = curl_exec($ch);
// Decode the response
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
echo $httpCode;
}
Can someone please tell me what am I doing wrong?
I am using Version 5.4.2 .