restpleskplesk-onyx

Creating a domain in Plesk's REST API


So, experimenting with Plesk's REST API (available as of version 17.8) for a project at work, and I'm starting to get a feel for it. I've been trying to experiment with adding a domain, but it's been giving me errors when I have to specify the hosting type.

The request body itself is as follows:

{ "name":"example.com", "hosting_type":"virtual", "description":"Description goes here" }

This gets the following cryptic response:

{ "code": 1014, "message": "htype\/vrt_hst is specified but there is no hosting\/vrt_hst" }

Per the documentation provided at /api/v2/swagger.yml, any of the following values should be allowed: virtual, standard_forwarding, frame_forwarding, none

No matter what I put in, however, I get a variant of the response above (htype\/{type} is specified but there is no hosting\/{type}).

At this point I'm kind of stuck; I'm not sure what to check, and any references when I try to look up the error code go to references on Plesk's XML API instead. What's the missing link here needed to get the request to work?


Solution

  • It looks like system user is not specified - hosting_settings. Try to add domain with full json request. Here is example:

    {
      "name": "example.com",
      "description": "My website",
      "hosting_type": "virtual",
      "hosting_settings": {
        "ftp_login": "test_login",
        "ftp_password": "test_pwd"
      },
      "base_domain": {
        "id": 7,
        "name": "a10-52-41-48.qa.plesk.ru",
        "guid": "b623e93d-dc72-4102-b5f0-ded427cf0fb1"
      },
      "parent_domain": {
        "id": 7,
        "name": "a10-52-41-48.qa.plesk.ru",
        "guid": "b623e93d-dc72-4102-b5f0-ded427cf0fb1"
      },
      "owner_client": {
        "id": 7,
        "login": "a10-52-41-48.qa.plesk.ru",
        "guid": "b623e93d-dc72-4102-b5f0-ded427cf0fb1",
        "external_id": "b623e93d-dc72-4102-b5f0-ded427cf0fb1"
      },
      "ipv4": [
        "212.192.122.46"
      ],
      "ipv6": [
        "2002:5bcc:18fd:c:123:123:123:123"
      ],
      "plan": {
        "name": "Unlimited"
      }
    }
    

    Examples for REST API https://app.swaggerhub.com/apis/plesk/api/v2#/Domains/post_domains