webiliza

Registered
Aug 6, 2018
2
0
1
Brasil
cPanel Access Level
Root Administrator
I use the API by calling the function:
PHP:
$cPanel = new cpanelAPI($cpaneluser, $cpanelpass, 'maindomain.com');
$response = $cPanel->api2->SubDomain->delsubdomain(['domain' => 'mysubtest.domain.com']);
returns error:
Code:
[QUOTE]Failed to find the domain(s): “mysubtest.domain.com.maindomain.com”. at /usr/local/cpanel/Cpanel/PHP/Config.pm line 255. Cpanel::PHP::Config::_get_php_config_for_domains(0, ARRAY(0x2ff8450)) called at /usr/local/cpanel/Cpanel/PHP/Config.pm line 275 Cpanel::PHP::Config::get_php_config_for_domains(ARRAY(0x2ff8450)) called at /usr/local/cpanel/Cpanel/PHPFPM.pm line 877 Cpanel::PHPFPM::_removedomain("mysubtest.domain.com.maindomain.com") called at /usr/local/cpanel/Cpanel/Sub.pm line 544 Cpanel::Sub::delsubdomain(__CPANEL_HIDDEN__, __CPANEL_HIDDEN__, __CPANEL_HIDDEN__, __CPANEL_HIDDEN__, __CPANEL_HIDDEN__, __CPANEL_HIDDEN__, __CPANEL_HIDDEN__, 0, ...) called at bin/admin/Cpanel/domain.pl line 227 bin::admin::Cpanel::domain::__ANON__() called at /usr/local/cpanel/3rdparty/perl/526/lib64/perl5/cpanel_lib/Try/Tiny.pm line 95 eval {...} called at /usr/local/cpanel/3rdparty/perl/526/lib64/perl5/cpanel_lib/Try/Tiny.pm line 90 Try::Tiny::try(CODE(0x2e95aa8), Try::Tiny::Catch=REF(0x124c030)) called at bin/admin/Cpanel/domain.pl line 231 bin::admin::Cpanel::domain::script("bin::admin::Cpanel::domain") called at bin/admin/Cpanel/domain.pl line 41[/QUOTE]
It seems to me that the function is joining the subdomain with the main domain and trying to remove "mysubtest.domain.com.maindomain.com".

Would this be a problem with the API or a bug with my function?

Can someone help me?
 
Last edited by a moderator:

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,261
463
Hello @webiliza,

It looks like you are using a dot instead of an underscore for the subdomain. Underscores should be used in place of dots when deleting the subdomain of an addon domain. See the following quote from our cPanel API 2 documentation:

To delete the subdomain of an addon domain, separate the subdomain with an underscore (_) instead of a dot (.). For example, use the following format:

subdomain_addondomain.tld
Thank you.