• 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 access thorugh url gives error

hamza-24

Basic Pleskian
Server operating system version
centOS 7
Plesk version and microupdate number
18.0.50
i am using the folowing code for creating user using rest API
<?php
// Define Plesk API credentials
$host = 'abc.xyz.123';
$login = 'admin';
$password = '@{dQr-r3$MCiWlZ';
// Define customer details
$customerName = 'testcustomer';
$customerEmail = '[email protected]';
$customerUsername = 'customer';
$customerPassword = 'temp1234@';
// Build API request body
$requestBody = <<<EOT
<customer>
<gen_info>
<pname>{$customerName}</pname>
<email>{$customerEmail}</email>
<username>{$customerUsername}</username>
<password>{$customerPassword}</password>
</gen_info>
</customer>
EOT;
// Send API request to create customer
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "https://{$host}:8443/api/v2/customers");
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Content-Type: application/xml',
'Authorization: Basic ' . base64_encode("{$login}:{$password}")
));
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $requestBody);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl);
curl_close($curl);
// Parse API response
$xml = simplexml_load_string($response);
if ($xml->xpath('//errtext')) {
echo "Error creating customer: {$xml->errtext}\n";
} else {
$customerId = $xml->id;
echo "Customer created with ID {$customerId}\n";
}
?>
but it gives me error page not found and no user is created
 
@hamza-24, just like any other web page you'll have to upload your test.php page to the webspace of a domain where you can access it via example.com/test.php.

It looks like you're new to PHP, maybe these free PHP courses will help you beter understand how to work with PHP.
 
sorry for my lack of knowledge but I just want to understand how I can connect the API so that user creation is automated when someone signups.
really confuse din that. @Kaspar
 
Your script is connecting to API via curl - it looks OK besides the xml/json part. Now you have to place your script somewhere so it can be called.
Talking in Plesk terms, you would create a domain with PHP enabled and upload it via File manager.

So the basic setup looks like this:
1. You have an API endpoints, provided by Plesk at https://<Plesk URL or IP>:8443/api/v2/<endpoint-name>
2. You have your domain https://some-domain.com created in Plesk
3. You upload a .php file (e.g. form.php) via File manager
4. You open https://some-domain.com/form.php in your browser and can see the results of your script execution
 
Back
Top