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 from WHM

Discussion in 'cPanel Developers' started by broncha, Jul 15, 2009.

  1. broncha

    broncha Active Member

    Joined:
    Feb 3, 2009
    Messages:
    32
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Kathmandu,Nepal
    cPanel Access Level:
    Root Administrator
    Hi

    I think we can call cpanel api through whm right?
    CallingAPIFunctions < AllDocumentation/AutomationIntegration < TWiki

    says that :Under certain circumstances, you may need to use the XML or JSON API as a "wrapper" to access the functions performed by API version 1 or version 2. You can do this from within either WebHost Manager or cPanel.

    This is what I did:
    in whm i hit :
    domain.com:2086/xml-api/cpanel?cpanel_xmlapi_user=root&cpanel_xmlapi_module=Email&cpanel_xmlapi_func=listpopswithdisk%20&cpanel_xmlapi_version=2&domain=somedomain.com

    and I got following result:
    <cpanelresult>
    <apiversion>2</apiversion>
    <func>listpopswithdisk </func>
    <module>Email</module>
    </cpanelresult>

    Did I go wrong somewhere? I need to be able to call Cpanel Api functions without logging in to respective cPanel but from WHM itself.

    HELP!!:confused:
     
    #1 broncha, Jul 15, 2009
    Last edited: Jul 15, 2009
  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
    The cpanel_xmlapi_user parameter indicates which cPanel account to execute this API2 function as. You should put the cPanel user's username here, not root.
     
  3. broncha

    broncha Active Member

    Joined:
    Feb 3, 2009
    Messages:
    32
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Kathmandu,Nepal
    cPanel Access Level:
    Root Administrator
    Hi

    I changed the username but the same result again..Can this be the problem in the cpanel itself?? coz I get this working :

    domain.com:2086/xml-api/cpanel?cpanel_xmlapi_user=username&cpanel_xmlapi_module=Rand&cpanel_xmlapi_func=getranddata&cpa nel_xmlapi_version=2&domain=somedomain.com

    This works for me...Why not other modules and functions??:confused:
     
  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
    Can you perform the function you are requesting via the APIs in cPanel? If yes, then it is not a cPanel issue.

    Are you still trying to do Email::listpopswithdisk like you were before? Be sure to trim the trailing space from listpopswithdisk if you are using the code you pasted earlier.

    If that doesn't work, please let me know what you are experiencing (error message, login screen etc.).
     
  5. broncha

    broncha Active Member

    Joined:
    Feb 3, 2009
    Messages:
    32
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Kathmandu,Nepal
    cPanel Access Level:
    Root Administrator
    Hi

    I tried the same with cPanel :

    somedomain.com:2082/xml-api/cpanel?cpanel_xmlapi_user=username&cpanel_xmlapi_modul e=Email&cpanel_xmlapi_func=listpopswithdisk&cpanel_xmlapi_version=2&domain=somedomain.com

    The result is:
    <cpanelresult>
    <apiversion>1</apiversion>
    <type>text</type>

    <data>
    <result>0</result>
    <reason>No Valid Command Given.</reason>
    </data>
    </cpanelresult>

    check these:
    This makes me think mine is not supporting API2 or what?? I've used cpanel_xmlapi_version=2 in the command!!
     
  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
    This can happen if you have spaces in your URL. Please remove all spaces.
     
  7. broncha

    broncha Active Member

    Joined:
    Feb 3, 2009
    Messages:
    32
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Kathmandu,Nepal
    cPanel Access Level:
    Root Administrator
    Thanks for that quick response.
    I got it working in cPanel but still not in WHM.
    Any idea why??
    I copied and pasted the same command..which worked from cPanel
     
  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
    Maybe it's the username parameter?

    In cPanel, the username parameter is essentially ignored since you only have access to 1 account so the APIs assume you're performing the task on the only account you have access to.

    In WHM, the username parameter is important since as a reseller or root user you can have access to many accounts. Be sure to specify the username parameter correctly and remember that it is case-sensitive.

    If you insert a username that is wrong, the API call can still work in cPanel. However since this is important in WHM, it will cause the API call to malfunction in WHM.
     
  9. broncha

    broncha Active Member

    Joined:
    Feb 3, 2009
    Messages:
    32
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Kathmandu,Nepal
    cPanel Access Level:
    Root Administrator
    Hi I double checked it. Everything is correct..just not working for some reason...And I can't figure out why???
     
  10. 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
    Drop me an email to sales@cpanel.net with ATTN: DavidG in the subject line so you and I can work on this in private.
     
  11. jlone

    jlone Registered

    Joined:
    Jul 18, 2009
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    cPanel API

    I'm getting the same thing when I try it. No spaces, and the syntax seems to be correct.
     
  12. 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
    Please provide your full cPanel version information as well as the API URL you are sending to WHM or cPanel. This will allow me to assist you.
     
  13. broncha

    broncha Active Member

    Joined:
    Feb 3, 2009
    Messages:
    32
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Kathmandu,Nepal
    cPanel Access Level:
    Root Administrator
    Hehe Documentation glitch . The fast mode takes only 'user' as parameter and not 'cpanel_xmlapi_user'

    The documentation has already been updated.
    Thanks Matt.
     
  14. 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
    broncha, that's not entire correctly, but that is the jist of the issue.

    In some cases cpanel_xmlapi_user does not work - it appears to be an issue with the 11.24.4 version (while it seems to work on 11.24.7+ )
     
Loading...

Share This Page