• 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
  • Inviting everyone to the UX test of a new security feature in the WP Toolkit
    For WordPress site owners, threats posed by hackers are ever-present. Because of this, we are developing a new security feature for the WP Toolkit. If the topic of WordPress website security is relevant to you, we would be grateful if you could share your experience and help us test the usability of this feature. We invite you to join us for a 1-hour online session via Google Meet. Select a convenient meeting time with our friendly UX staff here.

Question REST Api How to create Webspace

mhalterbeck

New Pleskian
Hi everyone,

how do I create a Webhosting via REST Api?

I already created a User via API but my Problem is that I cant create a Webspace.

I used the following code:

<packet>
<webspace>
<add>
<gen_setup>
<name>domain_to_add</name>
<owner-id>2</owner-id>
<htype>vrt_hst</htype>
<ip_address>IP_of_plesk</ip_address>
<status>0</status>
</gen_setup>
<hosting>
<vrt_hst>
<property>
<name>ftp_login</name>
<value>ftp_login</value>
</property>
<property>
<name>ftp_password</name>
<value>ftp_password</value>
</property>
<property>
<name>fp</name>
<value>false</value>
</property>
<property>
<name>fp_ssl</name>
<value>false</value>
</property>
<property>
<name>fp_auth</name>
<value></value>
</property>
<property>
<name>fp_admin_login</name>
<value></value>
</property>
<property>
<name>fp_admin_password</name>
<value></value>
</property>
<property>
<name>ssl</name>
<value>true</value>
</property>
<property>
<name>php</name>
<value>true</value>
</property>
<property>
<name>php_handler_id</name>
<value>plesk-php74-fastcgi</value>
</property>
<property>
<name>ssi</name>
<value>false</value>
</property>
<property>
<name>cgi</name>
<value>true</value>
</property>
<property>
<name>perl</name>
<value>true</value>
</property>
<property>
<name>asp</name>
<value>false</value>
</property>
<property>
<name>asp_dot_net</name>
<value>false</value>
</property>
<property>
<name>webstat</name>
<value>awstats</value>
</property>
<property>
<name>webstat_protected</name>
<value>true</value>
</property>
<property>
<name>errdocs</name>
<value>false</value>
</property>
<property>
<name>php_version</name>
<value>7.4</value>
</property>
<property>
<name>webdeploy</name>
<value>false</value>
</property>
<property>
<name>www_root</name>
<value>/sample4</value>
</property>
<ip_address>IP_of_plesk</ip_address>
</vrt_hst>
</hosting>
<plan-name>Unlimited</plan-name>
</add>
</webspace>
</packet>
 
There is the REST API and the XML RCP API. The code you've posted is for the later. It will not work if you send it to the REST API. However I assume you are actually using the XML RCP API and mixed up the API names. If the XML code you are using isn't working then you'll likely get an error returned from the API. What does it say?

If you're looking for an example for the actual REST API to a look the code bellow.
{
"name": "example.com",
"description": "My website",
"hosting_type": "virtual",
"hosting_settings": {
"ftp_login": "test_login",
"ftp_password": "changeme1Q**"
},
"base_domain": {
"id": 7,
"name": "example.com",
"guid": "b623e93d-dc72-4102-b5f0-ded427cf0fb1"
},
"parent_domain": {
"id": 7,
"name": "example.com",
"guid": "b623e93d-dc72-4102-b5f0-ded427cf0fb1"
},
"owner_client": {
"id": 7,
"login": "owner",
"guid": "b623e93d-dc72-4102-b5f0-ded427cf0fb1",
"external_id": "b623e93d-dc72-4102-b5f0-ded427cf0fb1"
},
"ip_addresses": [
"93.184.216.34",
"2606:2800:220:1:248:1893:25c8:1946"
],
"ipv4": [
"93.184.216.34"
],
"ipv6": [
"2606:2800:220:1:248:1893:25c8:1946"
],
"plan": {
"name": "Unlimited"
}
}
 
Back
Top