• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Odd issue with RPC API

CruzMark

Regular Pleskian
I'm having an odd issue with the RPC API. Tools that work on Plesk 8.x servers are getting a 400 error when trying to connect to a Plesk 9.5 server. These are simple things, such as retrieving account information. There are no errors in /var/log/sw-cp-server/error_log and I can see the 400 errors in the /usr/local/psa/admin/logs/httpsd_access_log file.

However, I can't seem to find any info on what is actually causing these errors. Any ideas? Any other info I could provide to help pinpoint this issue?

Thanks.
 
Try to use following Perl script - http://forum.parallels.com/showpost.php?p=389445&postcount=6
Or following php script:

Code:
<?php

$host="IP_here";
$login="admin";
$passwd="password_here";
$port=8443;

$data = <<<EOF
[B]<packet version="1.4.1.1"><domain>
<set>
......
</set>
</domain>
</packet>[/B]
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, $passwd, $host, $port);

?>
 
Last edited:
Also could you please post here your API request and response. We will check it.
 
Okay, we put together a test perl script based on the examples above, running a <get-limit-descriptor> against an existing domain ID. Here are the results:

The script works when run against a Plesk FreeBSD 6.x machine running the 8.6.0 control panel:

****************************************************

----- REQUEST ---------------------
REQUEST_HEADERS=$VAR1 = 'HTTP_AUTH_LOGIN: admin
HTTP_AUTH_PASSWD: ********
HTTP_PRETTY_PRINT: TRUE
Content-Type: text/xml
';

REQUEST DATA
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<packet version ="1.5.0.0">
<domain>
<get-limit-descriptor>
<filter>
<id>9</id>
</filter>
</get-limit-descriptor>
</domain>
</packet>

----- RESULT ------------------------
REPLY_HEADERS=$VAR1 = {
'CACHE-CONTROL' => 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0',
'LAST-MODIFIED' => 'Wed, 05 May 2010 22:32:04 GMT',
'DATE' => 'Wed, 05 May 2010 22:32:04 GMT',
'CONNECTION' => 'close',
'P3P' => 'CP="NON COR CURa ADMa OUR NOR UNI COM NAV STA"',
'CONTENT-TYPE' => 'text/xml',
'EXPIRES' => 'Thu, 19 Nov 1981 08:52:00 GMT',
'SERVER' => 'Apache',
'PRAGMA' => 'no-cache',
'SET-COOKIE' => 'locale=en-US; expires=Thu, 05-May-2011 22:32:04 GMT; path=/',
'X-POWERED-BY' => 'PHP/5.2.6'
};

REPLY_TYPE=HTTP/1.1 200 OK
REPLY_DATA:
<?xml version="1.0" encoding="UTF-8"?>
<packet version="1.5.0.0">
<domain>
<get-limit-descriptor>
<result>
<status>ok</status>
<filter-id>9</filter-id>
<id>9</id>
<descriptor>
<property>
<name>max_subdom</name>
<type>int</type>
<writable-by>admin</writable-by>
<label>limit__max_subdom</label>
<extension>
<shared>false</shared>
</extension>
</property>
<property>
<name>max_dom_aliases</name>
<type>int</type>
<writable-by>admin</writable-by>
<label>limit__max_dom_aliases</label>
<extension>
<shared>false</shared>
</extension>
</property>
<property>
<name>disk_space</name>
<type>bytes</type>
<writable-by>admin</writable-by>
<label>limit__disk_space</label>
<extension>
<shared>false</shared>
</extension>
</property>
<property>
<name>max_traffic</name>
<type>bytes</type>
<writable-by>admin</writable-by>
<label>limit__max_traffic</label>
<extension>
<shared>false</shared>
</extension>
</property>
<property>
<name>max_wu</name>
<type>int</type>
<writable-by>admin</writable-by>
<label>limit__max_wu</label>
<extension>
<shared>false</shared>
</extension>
</property>
<property>
<name>max_db</name>
<type>int</type>
<writable-by>admin</writable-by>
<label>limit__max_db</label>
<extension>
<shared>false</shared>
</extension>
</property>
<property>
<name>max_box</name>
<type>int</type>
<writable-by>admin</writable-by>
<label>limit__max_box</label>
<extension>
<shared>false</shared>
</extension>
</property>
<property>
<name>mbox_quota</name>
<type>bytes</type>
<writable-by>admin</writable-by>
<label>limit__mbox_quota</label>
<extension>
<shared>true</shared>
</extension>
</property>
<property>
<name>max_redir</name>
<type>int</type>
<writable-by>admin</writable-by>
<label>limit__max_redir</label>
<extension>
<shared>false</shared>
</extension>
</property>
<property>
<name>max_mg</name>
<type>int</type>
<writable-by>admin</writable-by>
<label>limit__max_mg</label>
<extension>
<shared>false</shared>
</extension>
</property>
<property>
<name>max_resp</name>
<type>int</type>
<writable-by>admin</writable-by>
<label>limit__max_resp</label>
<extension>
<shared>false</shared>
</extension>
</property>
<property>
<name>max_maillists</name>
<type>int</type>
<writable-by>admin</writable-by>
<label>limit__max_maillists</label>
<extension>
<shared>false</shared>
</extension>
</property>
<property>
<name>max_webapps</name>
<type>int</type>
<writable-by>admin</writable-by>
<label>limit__max_webapps</label>
<extension>
<shared>false</shared>
</extension>
</property>
<property>
<name>expiration</name>
<type>date</type>
<writable-by>admin</writable-by>
<label>limit__expiration</label>
<extension>
<shared>true</shared>
</extension>
</property>
</descriptor>
</result>
</get-limit-descriptor>
</domain>
</packet>
****************************************************

And here's the script NOT working when querying the Centos 5.4 server running Plesk 9.5.1:


----- REQUEST ---------------------
REQUEST_HEADERS=$VAR1 = 'HTTP_AUTH_LOGIN: admin
HTTP_AUTH_PASSWD: ********
HTTP_PRETTY_PRINT: TRUE
Content-Type: text/xml
';

REQUEST DATA
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<packet version ="1.5.0.0">
<domain>
<get-limit-descriptor>
<filter>
<id>3</id>
</filter>
</get-limit-descriptor>
</domain>
</packet>

----- RESULT ------------------------
REPLY_HEADERS=$VAR1 = {
'CONTENT-TYPE' => 'text/html',
'DATE' => 'Wed, 05 May 2010 22:39:32 GMT',
'SERVER' => 'sw-cp-server',
'CONTENT-LENGTH' => '349',
'CONNECTION' => 'close'
};

REPLY_TYPE=HTTP/1.0 400 Bad Request
REPLY_DATA:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>400 - Bad Request</title>
</head>
<body>
<h1>400 - Bad Request</h1>
</body>
</html>

****************************************************
 
We have performed some tests and found that seems there is problem in mentioned perl script - post_https function adds Content-Type and Content-Length headers and as result sw-cp-server gets POST request where Content-Type and Content-Length headers are duplicated and it leads to 400 error.

Therefore I recommend you use php script instead perl script.
 
We have performed some tests and found that seems there is problem in mentioned perl script - post_https function adds Content-Type and Content-Length headers and as result sw-cp-server gets POST request where Content-Type and Content-Length headers are duplicated and it leads to 400 error.

Therefore I recommend you use php script instead perl script.

I've have half a dozen other servers running 8.x and the scripts are highly evolved for our customer support system. Telling me to convert them to PHP is total BS. Why doesn't Parallels FIX what they broke with the 9.x system?
 
I'm still waiting for a resolution on this.

Does anyone have a way to do this via Curl in Perl. It might be easier to convert the scripts from using Net:SSLeay to Curl, and it would make things much faster if someone could toss the code my way to get me started.

Thanks!
 
FYI, got an email from support today with a solution that uses Crypt:SSLeay instead of Net::SSLeay. We're working with it now to see if it solves our issues.
 
Back
Top