• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • 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.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Issue plesk api add new domain

SanDisk

New Pleskian
hello, my customer asked me to create simple script for add new domain in plesk panel with api, im created this code : [Python] import requests import ssl ssl._create_default_https_context = ssl._create_unv - Pastebin.com

'''

PHP:
<?xml version='1.0' encoding='UTF-8' ?><packet version='1.5.0.0'>
    <domain>
    <add>
      <gen_setup>
         <name>google.com</name>
         <client_id>1</client_id>
         <ip_address>127.0.0.1</ip_address>
         <status>0</status>
      </gen_setup>
      <hosting>
         <vrt_hst>
             <ftp_login>dsakdakd</ftp_login>
             <ftp_password>sdffsdfsdfsddfs</ftp_password>
             <php>true</php>
             <ssi>true</ssi>
             <cgi>true</cgi>
             <php_safe_mode>false</php_safe_mode>
             <ip_address>127.0.0.01</ip_address>
         </vrt_hst>
      </hosting>
    </add>
    </domain>
    </packet>
'''

return :

Code:
<?xml version="1.0"?>
        <packet version="1.5.0.0">
                <system>
                        <status>error</status>
                        <errcode>1014</errcode>
                        <errtext>Parser error: Request is invalid</errtext>
                </system>               <output>
                &lt;br /&gt;
&lt;b&gt;Warning&lt;/b&gt;:  DOMDocument::schemaValidate() [&lt;a href='domdocum
ent.schemavalidate'&gt;domdocument.schemavalidate&lt;/a&gt;]: Element 'ftp_login
': This element is not expected. Expected is ( property ). in &lt;b&gt;C:\Progra
m Files (x86)\Parallels\Plesk\admin\plib\api-rpc\ExpandXMLLib.php&lt;/b&gt; on l
ine &lt;b&gt;56&lt;/b&gt;&lt;br /&gt;

                </output>       </packet>
where im wrong ?
 
It should be with <property> operator, like

Code:
<vrt_hst>
   <property>
       <name>ftp_login</name>
       <value>mylogin</value>
   </property>
   <property>
       <name>ftp_password</name>
       <value>mypassword</value>
   </property>
   <ip_address>123.123.123.123</ip_address>
   <ip_address>2002:5bcc:18fd:c:123:123:123:123</ip_address>
</vrt_hst>
 
Code:
<?xml version="1.0"?>
        <packet version="1.5.0.0">
                <system>
                        <status>error</status>
                        <errcode>1014</errcode>
                        <errtext>Parser error: Request is invalid</errtext>
                </system>               <output>
                &lt;br /&gt;
&lt;b&gt;Warning&lt;/b&gt;:  DOMDocument::schemaValidate() [&lt;a href='domdocum
ent.schemavalidate'&gt;domdocument.schemavalidate&lt;/a&gt;]: Element 'ftp_login
': This element is not expected. Expected is ( property ). in &lt;b&gt;C:\Progra
m Files (x86)\Parallels\Plesk\admin\plib\api-rpc\ExpandXMLLib.php&lt;/b&gt; on l
ine &lt;b&gt;56&lt;/b&gt;&lt;br /&gt;

                </output>       </packet>
same error
 
Code:
<packet version='1.5.0.0'>
        <domain>
        <add>
          <gen_setup>
             <name>google.com</name>
             <client_id>1</client_id>
             <ip_address>10.58.108.100</ip_address>
             <status>0</status>
          </gen_setup>
          <hosting>
             <vrt_hst>
             <property>
                <name>ftp_login</name>
                <value>mylogin</value>
            </property>
            <property>
                <name>ftp_password</name>
                <value>mypassword</value>
            </property>
                 <ip_address>10.58.108.100</ip_address>
             </vrt_hst>
          </hosting>
        </add>
        </domain>
        </packet>

This works fine for me.
 
Back
Top