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.

CPanel API Help

Discussion in 'cPanel Developers' started by indicom, Aug 15, 2008.

Thread Status:
Not open for further replies.
  1. indicom

    indicom Registered

    Joined:
    Aug 15, 2008
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Hello,

    I am into PHP programming and I plan to use CPanel XMLAPI to call API2 functions in one of my application.

    I have the following URL which I wrote to check my scripts functionality.

    https://domainname.com:2087/xml-api/cpanel?user=bob&xmlin=<cpanelaction>
    <module>email</module><func>listpopswithdisk</func>
    <args><domain>domainname.com</domain></args></cpanelaction>

    (Note: The above is in one line only; I broke it up a bit to keep it from "breaking" the window)

    But when I run it gives me the following output

    <cpanelresult>
    <data>
    <result>0</result>
    <reason>Unknown Error</reason>
    </data>
    </cpanelresult>

    Any idea why I get such an output. Is there anything wrong in the URL formation or am I missing something that needs to be taken care of ..

    Looking forward for all possible inputs.

    Thanks.
     
  2. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    This was a flaw in recent builds of cPanel/WHM. This will be resolved in build 26636. Updates with build number 26636 or higher will fix this issue once they are released.
     
  3. indicom

    indicom Registered

    Joined:
    Aug 15, 2008
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Hello David,

    My webhost has updated the cPanel to the latest update avilable.

    Given below is the version info for your reference.

    WHM 11.23.2 cPanel 11.23.5-C26642

    I tried executing the following URL after the cPanel version update.

    https://domainname.com:2087/xml-api/cpanel?user=bob&xmlin=<cpanelaction>
    <module>email</module><func>listpopswithdisk</func>
    <args><domain>domainname.com</domain></args></cpanelaction>

    (Note: The above is in one line only; I broke it up a bit to keep it from "breaking" the window)

    It gave me an ERROR allthough of a different kind as compared to the previous one.


    <fatalerror>[a fatal error or timeout occurred while processing this directive]</fatalerror>
    <fatalerror>[a fatal error or timeout occurred while processing this directive]</fatalerror>
    <fatalerror>[a fatal error or timeout occurred while processing this directive]</fatalerror>
    <fatalerror>[a fatal error or timeout occurred while processing this directive]</fatalerror> <cpanelresult>


    Any idea why I get such an output.

    Is it due the new version of cPanel or is any parameter missing in relation to the new cPanel version...

    Looking forward for all possible inputs.

    Thanks
     
  4. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    After some lengthy discussion with our QA folks and being able to replicate this issue, just change email to Email (case-sensitive) and it should work.

    We are currently in the process of having the documentation updated.
     
  5. indicom

    indicom Registered

    Joined:
    Aug 15, 2008
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Adding POP Email Account

    Thanks David for the info. The URL is now generating desired output.

    Now comming to the actual part. Using XMl API I plan to use some functions that are not a part of your API2 documentation. Is it possible ? YES / NO

    I tried to implement the same. I have the following URL which add a new POP Mail account for a given domain.

    https://domain.com:2087/xml-api/cpanel?user=bob&xmlin=
    <cpanelaction><module>Email</module>
    <func>addpop</func><args><email>test@domain.com</email>
    <password>abc</password><quota>10</quota>
    <domain>domain.com</domain></args></cpanelaction>

    (Note: The above is in one line only; I broke it up a bit to keep it from "breaking" the window)

    Allthough the output does not give me any error .. but on the contrary it does not create the POP Email account as requested.

    Am I missing any thing here..??

    Thanks
     
  6. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Yes, you can use undocumented API1 and API2 calls.

    There's a few things wrong with that API call you provided. First, you are using API2 syntax for an API1 function (note the format Module="function()" used in API1 rather than Module::function used in API2).

    Secondly, the first parameter should only be test, not test@domain.com. By using test@domain.com, you are creating the email address test@domain.com@domain.com (as the domain is added to the email address in creating the mail account). You can view the form used to create an email account in x3 to verify this :).
     
  7. indicom

    indicom Registered

    Joined:
    Aug 15, 2008
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Thanks again .. for helping me out. The URL worked after I reframed it as per your inputs.

    One more query here, regarding deleting a pop email account..

    https://domain.com:2087/xml-api/cpanel?user=bob&xmlin=<cpanelaction>
    <module>Email</module><func>delpop</func>
    <apiversion>1</apiversion>
    <args>test</args><args>0</args><args>domain.com</args></cpanelaction>

    I framed the above URL as per the function call listed under X3.. but it does not give me the desired result.. instead it gives me fatalerror message.

    Any idea why such an output ? Is the parameter sequence incorrect ?
    Or something else is missing.. ?

    Thanks
     
  8. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    A fix for this issue just needs to get through some quality assurance testing before it will propagate to the builds. I have no ETA on this but I will update this thread when this fix starts propagating. (Internal Case 8786)
     
  9. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
  10. ldsuva

    ldsuva Member

    Joined:
    Mar 16, 2009
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    <fatalerror>[a fatal error or timeout occurred while processing this directive]</fata

    Can you please assist me, I am having same issue,Below is code.

    $whmusername = "root";
    $whmpassword = "XXXX";
    $query ="https://IP:2087/xml-api/cpanel?user=raksthe1&xmlin=<cpanelaction><module>Email</module><func>listPopswithdisk</func><args><domain>raksthelds.com</domain></args></cpanelaction>";
    $curl = curl_init();

    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER,0);

    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,0);

    curl_setopt($curl, CURLOPT_HEADER,0);

    curl_setopt($curl, CURLOPT_RETURNTRANSFER,1);

    curl_setopt($curl, CURLOPT_USERPWD, $whmusername.":".$whmpassword);

    curl_setopt($curl, CURLOPT_URL, $query);

    $result = curl_exec($curl);
    curl_close($curl);
     
  11. cPanelKenneth

    cPanelKenneth cPanel Development
    Staff Member

    Joined:
    Apr 7, 2006
    Messages:
    4,458
    Likes Received:
    22
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    Please don't re-open old threads.

    When asking for help it is important to include error message output.
     
Loading...
Thread Status:
Not open for further replies.

Share This Page