• We value your experience with Plesk during 2026
    Please help us understand which Plesk features made your work easier this year, what is still missing and how AI should help you in Plesk ?
    Take this short 5-minutes survey. Your answers go straight into the Plesk roadmap for 2027.

I am not getting any API response from the plesk panel.

S

Sam1315

Guest
Hi All,
I am getting the following response: 'Empty reply from server'.
ERROR: 52 (Nothing was returned from the server)
I am not getting any response from the plesk panel.

I am really not sure what could be wrong. When I use administrator user/pass to log on to the plesk panel, it works fine.

I'm creating the following xml packet request;

XML version is '1.0', with 'UTF-8' encoding.

<packet version="1.4.2.0">
<mail>
<create>
<filter>
<domain_id>1</domain_id>
<mailname>
<name>test_mail_name</name>
<cp_access>
<enabled>true</enabled>
</cp_access>
</mailname>
</filter>
</create>
</mail>
</packet>

My cUrl request is :
$ch = curl_init();
$url = "https://xxxxxxxx:8443/enterprise/control/agent.php";
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, "$packet");
curl_setopt($ch, CURLOPT_HTTPHEADER, array("HTTP_AUTH_LOGIN: {$login}",
"HTTP_AUTH_PASSWD: {$password}",
"HTTP_PRETTY_PRINT: TRUE","Content-Length: 1398",
"Content-Type: text/xml"));

My API RPC v.1.4.2.0
Plesk Panel version : 9.3.0
OS of the control panel: CentOS (Linux 2.6.18-164.11.1.el5)

Any help is greatly appreciated.

Thanks
 
Try to use following PHP script:

<?php

$host="IP_of_server";
$login="admin";
$passwd="Password_here";
$port=8443;

$data = <<<EOF
<packet version="1.4.2.0">
<mail>
<create>
<filter>
<domain_id>1</domain_id>
<mailname>
<name>test_mail_name</name>
<cp_access>
<enabled>true</enabled>
</cp_access>
</mailname>
</filter>
</create>
</mail>
</packet>
EOF;

function write_callback($ch, $data) {
echo $data;
return strlen($data);
}

function sendCommand($data, $login, $passwd, $host, $port=8443) {
$script = "enterprise/control/agent.php";
$url = "https://$host:$port/$script";
$headers = array(
"HTTP_AUTH_OP: $operator",
"HTTP_AUTH_LOGIN: $login",
"HTTP_AUTH_PASSWD: $passwd",
"HTTP_PRETTY_PRINT: TRUE",
"Content-Type: text/xml",
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_HTTPHEADER, &$headers);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_WRITEFUNCTION, write_callback);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
$result = curl_exec($ch);
if (!$result) {
echo "\n\n-------------------------\ncURL error number:".curl_errno($ch);
echo "\n\ncURL error:".curl_error($ch);
}
curl_close($ch);
return;
}
sendCommand($data, $login, $pass, $host, $port);

?>
 
Thank you for the quick response

It worked and I have created new mail account.
Please note the following changes. I hope it will help someone.

1. Call-time pass-by-reference has been deprecated. So changed the call to:
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

2. Use of undefined constant write_callback - assumed 'write_callback'.
3. error 1014 Parser error: Request is invalid.
(1014 Parsing error: wrong format of XML request.)
Change the cp_access node to the currect format.
<permissions>
<cp_access>true</cp_access>
</permissions>

Once again Thank you :)
 
Back
Top