Skip to main content

Nested subdomain Creation

Comments

7 comments

  • Robertfayez
    Anyone know how to create sub2.sub1.domain.com using XMLapi? where sub1 is an A record (a new account) under the main domain.
    0
  • cPanelMichael
    Hello :) Please ensure you follow the guidelines for this function: API2 Function - addsubdomain I tested with the following JSON-API call and it worked well: /json-api/cpanel?cpanel_jsonapi_apiversion=2&cpanel_jsonapi_module=SubDomain&cpanel_jsonapi_func=addsubdomain&domain=test1.test2&rootdomain=cptesting.com
    Notice how "test1.test2" is used for the "domain" parameter without the root domain name. Thank you.
    0
  • Robertfayez
    Thank you Michael, It's clear now I should use Domain:test1.dev Rootdomain:maindomain.com and not Domain:test1 Rootdomain:dev.maindomain.com Thanks a lot, But when I used it, I got this message: Array ( [apiversion] => 2 [data] => Array ( [reason] => The domain "dev.worksitesimple.com"" does not exist. [result] => 0 ) [error] => The domain "dev.worksitesimple.com"" does not exist. [event] => Array ( [result] => 1 ) [func] => addsubdomain [module] => SubDomain )
    0
  • cPanelMichael
    Could you post the code you are using for the creation? Note that you can enable the "API Shell" option in cPanel to make sure you are using the correct parameters: API Shell Thank you.
    0
  • Robertfayez
    Hi Michael, Thank you for your help, I really appreciate it, here you go the code am using password_auth("".$cpanelUsername."","".$cpanelPassword.""); $xmlapi->set_debug(1); $xmlapi->set_output('array'); $xmlapi->set_port($cpanelPort); $addsub = $xmlapi->api2_query($cpanelUsername, "SubDomain", "addsubdomain", array( "rootdomain"=>$cpanelHost, "domain"=>"dev3.dev", "dir" => "/public_html/dev3" )); print_r($addsub); ?>
    Where I've already a new account called dev.maindomain.com, this created a DNS zone automatically. Thanks Robert
    0
  • Robertfayez
    It's working normally right now after updating the "domain" and $cpanelUsername variables.. I used the root username to authenticate, but the account user name to create the subdomain. Robert
    0
  • cPanelMichael
    I am happy to see you were able to address the issue. Thank you for updating us with the outcome. Thank you.
    0

Please sign in to leave a comment.