使用Plesk REST API创建域名遇1014错误的技术求助
That error 1014 you're hitting is a common gotcha with the Plesk REST API: you've specified a hosting_type, but haven't provided the required configuration details for that hosting type. The Swagger docs list valid hosting_type values, but they don't make it obvious that each type requires a matching nested hosting object with specific settings.
Let's break down the solution for each hosting type:
1. For virtual hosting type
This is the most common scenario for a standard website domain. You need to add a hosting block with a vrt_hst object containing necessary FTP and IP settings. Here's a valid request body:
{ "name": "example.com", "hosting_type": "virtual", "description": "Description goes here", "hosting": { "vrt_hst": { "ftp_login": "example_ftp_user", "ftp_password": "YourStrongPassword123!", "ip_address": "192.168.1.100", "hard_quota": -1 // -1 means no disk quota limit } } }
Make sure the ip_address matches an IP available in your Plesk server's pool. You can omit hard_quota if you want to use the server's default quota.
2. For standard_forwarding (301/302 redirects)
Add a std_fwd block under hosting to define the redirect destination:
{ "name": "example.com", "hosting_type": "standard_forwarding", "description": "Redirect to target site", "hosting": { "std_fwd": { "destination": "https://your-target-site.com", "is_frame": false // Set to true for 302 redirect; false for permanent 301 } } }
3. For frame_forwarding (iframe-based forwarding)
Use the frwd block to specify the destination and optional frame title:
{ "name": "example.com", "hosting_type": "frame_forwarding", "description": "Frame-forward to target", "hosting": { "frwd": { "destination": "https://your-target-site.com", "frame_title": "Example Domain" } } }
4. For none (no hosting attached)
If you just want to register the domain without any hosting services, you can omit the hosting block entirely:
{ "name": "example.com", "hosting_type": "none", "description": "Domain without hosting" }
Key Notes:
- Always cross-check the Swagger docs for exact required fields for each hosting type (e.g.,
vrt_hstmight needphp_handler_idif you require PHP support). - Ensure your API user has necessary permissions (Domain Management, Hosting Configuration) to create domains with the specified hosting type.
- The error message
htype/{type} is specified but there is no hosting/{type}is Plesk's way of saying: "You told me to use this hosting type, but didn't give me the settings to set it up."
内容的提问来源于stack exchange,提问作者Kaji

