• 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

Question Virtual Host Template Applied to REST API Domains?

jPG

New Pleskian
Hello,

I recently configured a virtual host template successfully applied to any new domain created manually in Plesk. When I use the Plesk REST API to create domains, the virtual host template is not applied. Is it possible to apply a virtual host template on API created domains?

Here's my current PHP API call function:

function createDomain($domain, $secretKey, $parentDomainGuid, $ownerClientGuid, $ipv4, $ipv6, $domainId){
$url = "https://" . $domain . ":8443/api/v2/domains";
$folder = $this->account->install_folder;
$request = array (
'name' => $folder . ' . ' . $domain,
'hosting_type' => 'virtual',
'hosting_settings' =>
array (
"www_root" => 'httpdocs/' . $folder,
'certificate_name'=> 'Lets Encrypt ' . $domain
),
'parent_domain' =>
array (
'id' => $domainId,
'name' => $domain,
'guid' => $parentDomainGuid,
),
'owner_client' =>
array (
'id' => 1,
'login' => 'admin',
'guid' => $ownerClientGuid,
'external_id' => '',
),
'ipv4' =>
array (
0 => $ipv4,
),
'ipv6' =>
array (
0 => $ipv6,
),
'plan' =>
array (
'name' => 'Unlimited',
),
);
}

Thanks in advance!
jPG
 
Also, could you explain your issue in more detail? What's different on your domain when you create it trough the REST API compared to when you manually create a domain?
 
Yeah, sorry. I am running Plesk Obsidian 18.0.42 and trying to add a vhost_nginx.conf file to the virtual template "conf" folder. It works like a charm for domains I create manually but not for the ones created by the API. Just wondering if I am missing something...
 
I would suggest contacting Plesk support and explaining your issue in detail to them so they can investigate the issue. Perhaps it's an undocumented limitation on the REST API or even a bug. If it's not, I am sure they can offer a possible solution.
 
Back
Top