• Plesk Uservoice will be deprecated by October. Moving forward, all product feature requests and improvement suggestions will be managed through our new platform Plesk Productboard.
    To continue sharing your ideas and feedback, please visit features.plesk.com

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