Community Forums
Connect with us on LinkedIn
Closed Thread
Results 1 to 11 of 11
  1. #1
    Registered User
    Join Date
    Aug 2008
    Posts
    4

    Default CPanel API Help

    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. #2
    Technical Product Specialist cPanelDavidG's Avatar
    Join Date
    Nov 2006
    Location
    Houston, TX
    Posts
    11,189
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    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. #3
    Registered User
    Join Date
    Aug 2008
    Posts
    4

    Default

    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. #4
    Technical Product Specialist cPanelDavidG's Avatar
    Join Date
    Nov 2006
    Location
    Houston, TX
    Posts
    11,189
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    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. #5
    Registered User
    Join Date
    Aug 2008
    Posts
    4

    Default 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. #6
    Technical Product Specialist cPanelDavidG's Avatar
    Join Date
    Nov 2006
    Location
    Houston, TX
    Posts
    11,189
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    Quote Originally Posted by indicom View Post
    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
    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. #7
    Registered User
    Join Date
    Aug 2008
    Posts
    4

    Default

    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. #8
    Technical Product Specialist cPanelDavidG's Avatar
    Join Date
    Nov 2006
    Location
    Houston, TX
    Posts
    11,189
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    Quote Originally Posted by indicom View Post
    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
    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. #9
    Technical Product Specialist cPanelDavidG's Avatar
    Join Date
    Nov 2006
    Location
    Houston, TX
    Posts
    11,189
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    This issue has been resolved in CURRENT 26765 and EDGE 26765. For more information visit, http://changelog.cpanel.net/

  10. #10
    Member
    Join Date
    Mar 2009
    Posts
    6

    Default <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. #11
    cPanel Development cpanelkenneth's Avatar
    Join Date
    Apr 2006
    Posts
    3,788
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    Please don't re-open old threads.

    When asking for help it is important to include error message output.
    Kenneth
    Product Manager
    cPanel, Inc.

Similar Threads & Tags
Similar threads

  1. Replies: 1
    Last Post: 06-04-2011, 09:52 AM
  2. cpanel api
    By eugui in forum cPanel Developers
    Replies: 3
    Last Post: 08-08-2008, 02:20 PM
  3. cpanel API
    By cpnaba in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 05-11-2007, 08:24 AM
  4. cpanel API
    By sangreal in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 12-25-2006, 01:13 AM
  5. CPanel API
    By davenarc in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 04-11-2004, 06:54 PM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube