Pierre Ringenbach
New Pleskian
- Server operating system version
- Ubuntu 22.04
- Plesk version and microupdate number
- 18.0.66 #2
Hi,
I'm learning how to manage my plesk users with the API (to do it automatically from another site), but, if I run my query, the 401 error still appears.
Do you have any ideas to solve this?
This is my request PHP :
And here is the site's response :

I have nothing in the F12 console
Thank you for your help
I'm learning how to manage my plesk users with the API (to do it automatically from another site), but, if I run my query, the 401 error still appears.
Do you have any ideas to solve this?
This is my request PHP :
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = $_POST['name'];
$email = $_POST['email'];
// Générer un mot de passe aléatoire
$password = bin2hex(random_bytes(8)); // Génère un mot de passe de 16 caractères
// Informations de l'API Plesk
$plesk_api_url = "https://domain:8443/api/v2/clients";
$api_key = "Key_API";
// Données à envoyer à l'API Plesk
$data = [
"name" => $name,
"email" => $email,
"password" => $password
];
// Configuration de la requête cURL
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $plesk_api_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Content-Type: application/json",
"X-API-Key: $api_key"
]);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
// Exécution de la requête
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($http_code == 201) {
echo "Utilisateur créé avec succès!<br>";
echo "Nom: $name<br>";
echo "Email: $email<br>";
echo "Mot de passe: $password<br>";
} else {
echo "Erreur lors de la création de l'utilisateur. Code HTTP: $http_code<br>";
echo "Réponse: $response";
}
curl_close($ch);
}
?>
And here is the site's response :

I have nothing in the F12 console
Thank you for your help