• Hi, Pleskians! We are running a UX testing of our upcoming product intended for server management and monitoring.
    We would like to invite you to have a call with us and have some fun checking our prototype. The agenda is pretty simple - we bring new design and some scenarios that you need to walk through and succeed. We will be watching and taking insights for further development of the design.
    If you would like to participate, please use this link to book a meeting. We will sent the link to the clickable prototype at the meeting.
  • (Plesk for Windows):
    MySQL Connector/ODBC 3.51, 5.1, and 5.3 are no longer shipped with Plesk because they have reached end of life. MariaDB Connector/ODBC 64-bit 3.2.4 is now used instead.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.

Question Error 200 delete User API REST

Pierre Ringenbach

New Pleskian
Server operating system version
Ubuntu 22.04
Plesk version and microupdate number
18.0.67
Hello,
I have a problem with my program that gives me a vague error.
I use REST API with a key generated with the extension "Keychain for API Secret Keys"

Everything works well (user creation, information retrieval, change account status) but it is impossible to delete the user.
Instead, it shows me the following error:
Error deleting user. HTTP Code: 200
API Response: { "id": 11, "created": "2025-03-07", "name": "Pierre", "company": "", "login": "[email protected]", "status": 1, "email": "[email protected]", "locale": "", "guid": "96s24355-3898-4055-982c-191df9ee9a32", "external_id": "", "description": "", "type": "customer" }
(API response data has been anonymized.)

Regarding the code I currently have, here it is:
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Supprimer un utilisateur Plesk</title>
</head>
<body>
<h1>Supprimer un utilisateur Plesk</h1>
<form action="delete_user.php" method="POST">
<label for="user_id">ID de l'utilisateur :</label>
<input type="text" id="user_id" name="user_id" required>
<button type="submit">Supprimer</button>
</form>
</body>
</html>
<?php
if (isset($_POST['user_id'])) {
$user_id = $_POST['user_id'];

// URL de l'API Plesk pour obtenir les informations d'un utilisateur
include'./settings/api_connect.php';
$url = $api_link . '/clients/' . $user_id;

// Initialisation de cURL
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'X-API-Key: ' . $api_key // Utilisation de la clé API
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

// Exécution de la requête
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);

// Fermeture de la session cURL
curl_close($ch);

// Vérification de la réponse
if ($http_code == 204) {
echo "L'utilisateur avec l'ID {$user_id} a été supprimé avec succès.";
} else {
echo "Erreur lors de la suppression de l'utilisateur. Code HTTP : {$http_code}";
echo "<br>Réponse de l'API : " . htmlentities($response);
}
} else {
echo "Aucun ID d'utilisateur n'a été fourni.";
}
?>
if anyone has the solution, I'm interested.
I really wonder why it refuses to delete the user and instead shows me his info.

Thank you very much for your help
 
An 200 status response code actually means that the request has been successful. Doesn't the customer get deleted?
 
Back
Top