The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

xml api2 delete addon domain help.

Discussion in 'cPanel Developers' started by sirdopes, Nov 10, 2009.

  1. sirdopes

    sirdopes Well-Known Member
    PartnerNOC

    Joined:
    Sep 25, 2007
    Messages:
    141
    Likes Received:
    0
    Trophy Points:
    16
    I am trying to delete an addon domain but I am getting

    <cpanelresult>
    <apiversion>2</apiversion>
    <data>
    <reason>Error from park wrapper: Sorry, you do not control the domain
    </reason>
    <result>0</result>
    </data>
    <func>deladdondomain</func>
    <module>AddonDomain</module>
    </cpanelresult>


    This is the call that I am doing.

    http://127.0.0.1:2086/xml-api/cpanel?user=$owner&xmlin=&xmlin=<cpanelaction><module>AddonDomain</module><func>deladdondomain</func><args>$addomain</args>$subdomain<args></args></cpanelaction>

    I am using the access hash for root to authenticate. Is this an easier way to do this?

    I am calling it from a perl script.
     
  2. MattDees

    MattDees cPanel Product Owner
    Staff Member

    Joined:
    Apr 29, 2005
    Messages:
    417
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Could you please open a ticket on this at tickets.cpanel.net/submit

    please title this ticket: ATTN matt (cannot remove addondomain via API)

    I will also need access to your server along with information on how to reproduce the issue (how to run your script, etc)
     
  3. sirdopes

    sirdopes Well-Known Member
    PartnerNOC

    Joined:
    Sep 25, 2007
    Messages:
    141
    Likes Received:
    0
    Trophy Points:
    16
    Can you just provide an example of how the call is supposed to work?

    The following is the cpanel error log.

    2009-11-11 16:27:45 warn [addondomain::deladdondomain] Encountered error in addondomain::deladdondomain: Error from park wrapper: Sorry, you do not control the domain
    at /usr/local/cpanel/Cpanel/EventHandler.pm line 48
    Cpanel::EventHandler::event(2, 'post', 'addondomain', 'deladdondomain', HASH(0x91e2c64), ARRAY(0xb91e614)) called at cpanel.pl line 5018
    main::api2_exec('AddonDomain', 'deladdondomain', HASH(0xb91e4f4), ARRAY(0xb91e47c)) called at cpanel.pl line 1571
    main::docpanelaction('<cpanelaction><module>AddonDomain</module><func>deladdondomain</func><args>addondomain1.com</args><args>addondomain1.test.c1sc0.org</args></cpanelaction>') called at cpanel.pl line 4816
    main::dotag(undef) called at cpanel.pl line 4691
    main::cpanel_parseblock(SCALAR(0x92bdcac)) called at cpanel.pl line 1238
     
    #3 sirdopes, Nov 11, 2009
    Last edited: Nov 11, 2009
  4. sandeep.kumar

    sandeep.kumar Registered

    Joined:
    Apr 21, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    This code is working for me. I hope it will solve your problem.


    PHP:
    $request "/frontend/x3/addon/dodeldomain.html?domain=$domain&subdomain=$subdomain";
            
                   
                         
    $sock = @fsockopen($this->host,2082);
                 if(!
    $sock)
                 {
                            return 
    false;
                 }

                 
    $authstr "$this->user:$this->pass";
                 
    $pass base64_encode($authstr);
                 
    $in "GET $request\r\n";
                 
    $in .= "HTTP/1.0\r\n";
                 
    $in .= "Host:$this->host\r\n";
                 
    $in .= "Authorization: Basic $pass\r\n";
                 
    $in .= "\r\n";
                 
    //process
                 
    fputs($sock$in);
                 while (!
    feof($sock)) {
                
    $result .= fgets ($sock1028);
                 }
                 
    fclose$sock );
     
  5. stevenbennett

    stevenbennett Registered

    Joined:
    Jul 28, 2010
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Noticed this here with no real answer. I just ran into issues with deladdondomain myself, using the xmlapi.php wrapper.

    I can easily do something like:

    Code:
    $result= $xmlapi->api2_query(CPANEL_XMLAPI_USER, 'AddonDomain', 'addaddondomain',
    		array("newdomain" => "somedomain.com",
    			"subdomain" => "somedomain",
    			"dir" => $dir,
    			"pass" => $pass));
    
    $listresult = $xmlapi->listaddondomains(CPANEL_XMLAPI_USER);
    
    ...and it will add the domain and display it in the list of domains. But if I then try the following:

    Code:
    $result = $xmlapi->api2_query(CPANEL_XMLAPI_USER, 'AddonDomain', 'deladdondomain',
    		array("domain" => "somedomain.com",
    			"subdomain" => "somedomain"));
    
    ...it will fail with an error: "Error from park wrapper: Sorry, I do not believe you control the subdomain for somedomain.com."

    After fiddling around with this, particularly looking at the links which are being generated by the addon control panel, I figured it out. Apparently the API treats the subdomain parameter differently between the addaddondomain call and the deladdondomain call.

    For the deladdondomain call, what it wants in subdomain is NOT the subdomain, but instead the user name plus main domain name which the addaddondomain command added to your account. This is what is returned as the "domainkey" field in the listaddondomains results. So the following code:

    Code:
    $result = $xmlapi->api2_query(CPANEL_XMLAPI_USER, 'AddonDomain', 'deladdondomain',
    		array("domain" => "somedomain.com",
    			"subdomain" => "somedomain_maindomain.com"));
    
    ...is what's needed to actually work, at least going through the PHP API. I'm not sure why this is the case, it contradicts the docs, so it's either a bug, or incorrect documentation. (As a sanity check to make sure I wasn't misinterpreting the docs, I tried changing the addaddondomain call to use the "somedomain_maindomain.com" format, and it didn't like that.)

    Having solved the issue, I wanted to post it here so others who are having trouble can find the solution.

    FYI, I've been doing this on CPanel 11.25 running on a shared hostgator account.
     
Loading...

Share This Page