• 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

Bug in Set Site API response

Amin Taheri

Golden Pleskian
Plesk Certified Professional
Hello,

Here is a sample where we are attempting to set a domain to use a new IP

<?xml version="1.0" encoding="UTF-8"?>
<packet version="1.6.3.5">
<site>
<set>
<filter>
<name>domainname.com</name>
</filter>
<values>
<hosting>
<vrt_hst>
<property>
<name>ip_address</name>
<value>10.7.71.240</value>
</property>
</vrt_hst>
</hosting>
</values>
</set>
</site>
</packet>

And here is the response - you can note that there are 2 result nodes while the API standard of all the other commands (and your documentation) only ever should have 1.

<?xml version="1.0" encoding="UTF-8"?>
<packet version="1.6.3.5">
<site>
<set>
<result>
<result>
<status>error</status>
<errcode>1013</errcode>
<errtext>Site does not exist</errtext>
<filter-id>domainname.com</filter-id>
<id>23</id>
</result>
</result>
</set>
</site>
</packet>

Also, I pass in the domain name domainname.com which does exist on the server, and I get back a <filter-id>domainnameid.com<filter-id> and an <id> node, it would appear that the command is using my string value domain name filter as a domain name (site) id instead.
 
What sort of output of following php script with XML request inside:

<?php

$host="10.58.165.199";
$login="admin";
$passwd="setup";
$port=8443;

$data = <<<EOF
<?xml version="1.0" encoding="UTF-8"?>
<packet version="1.6.3.5">
<site>
<set>
<filter>
<name>domainname.com</name>
</filter>
<values>
<hosting>
<vrt_hst>
<property>
<name>ip_address</name>
<value>10.7.71.240</value>
</property>
</vrt_hst>
</hosting>
</values>
</set>
</site>
</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_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);

?>

Change values here

$host="10.58.165.199";
$login="admin";
$passwd="setup";

and run it as

# php api.php
 
Its the same result as I posted previously.

PHP Notice: Use of undefined constant write_callback - assumed 'write_callback' in /root/test.php on line 50
* About to connect() to localhost port 8443
* Trying 127.0.0.1... * connected
* Connected to localhost (127.0.0.1) port 8443
* successfully set certificate verify locations:
* CAfile: /etc/pki/tls/certs/ca-bundle.crt
CApath: none
* SSL connection using DHE-RSA-AES256-SHA
* Server certificate:
* subject: /serialNumber=MkYyaE1LKEsvHz7hWy32XxZgjO-LfC30/C=US/O=www.my-server-name.com/OU=GT93730019/OU=See www.geotrust.com/resources/cps (c)12/OU=Domain Control Validated - QuickSSL(R)/CN=www.my-server-name.com
* start date: 2012-03-13 12:44:21 GMT
* expire date: 2014-06-14 21:15:40 GMT
* issuer: /C=US/O=GeoTrust Inc./OU=Domain Validated SSL/CN=GeoTrust DV SSL CA
* SSL certificate verify ok.
> POST /enterprise/control/agent.php HTTP/1.1
Host: localhost:8443
Accept: */*
HTTP_AUTH_LOGIN: *******
HTTP_AUTH_PASSWD: *******
HTTP_PRETTY_PRINT: TRUE
Content-Type: text/xml
Content-Length: 284

<?xml version="1.0" encoding="UTF-8"?>
<packet version="1.6.3.5">
<site>
<set>
<filter>
<name>domainname.com</name>
</filter>
<values>
<hosting>
<vrt_hst>
<property>
<name>ip_address</name>
<value>10.7.71.240</value>
</property>
</vrt_hst>
</hosting>
</values>
</set>
</site>
</packet>< HTTP/1.1 200 OK
< P3P: CP="NON COR CURa ADMa OUR NOR UNI COM NAV STA"
< Last-Modified: Wed, 07 Nov 2012 16:19:33 GMT
< Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
< Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
< content-type: text/xml
< Expires: Thu, 19 Nov 1981 08:52:00 GMT
< Pragma: no-cache
< Set-Cookie: PHPSESSID=2d5bdf8f1e712615b486a411a49dba53; path=/; secure; httponly
< Set-Cookie: locale=en-US; expires=Thu, 07-Nov-2013 16:19:33 GMT; path=/
< Set-Cookie: locale=en-US; expires=Thu, 07-Nov-2013 16:19:33 GMT; path=/
< Transfer-Encoding: chunked
< Date: Wed, 07 Nov 2012 16:19:34 GMT
< Server: sw-cp-server
<?xml version="1.0" encoding="UTF-8"?>
<packet version="1.6.3.5">
<site>
<set>
<result>
<result>
<status>error</status>
<errcode>1013</errcode>
<errtext>Site does not exist</errtext>
<filter-id>domainname.com</filter-id>
<id>23</id>
</result>
</result>
</set>
</site>
</packet>
* Connection #0 to host localhost left intact
* Closing connection #0
 
Back
Top