• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • We are looking for U.S.-based freelancer or agency working with SEO or WordPress for a quick 30-min interviews to gather feedback on XOVI, a successful German SEO tool we’re looking to launch in the U.S.
    If you qualify and participate, you’ll receive a $30 Amazon gift card as a thank-you. Please apply here. Thanks for helping shape a better SEO product for agencies!
  • 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