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 XMLAPI 1.0.3 - JSON Output

Discussion in 'cPanel Developers' started by netrix37, Mar 3, 2010.

  1. netrix37

    netrix37 Member

    Joined:
    Jul 13, 2006
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    I'm sure I'm missing something but if I do the following:

    Code:
    include("xmlapi.php");
    $ip = "hostname.com";
    $root_pass = "password";
    $account = "account";
    $xmlapi = new xmlapi($ip);
    $xmlapi->hash_auth("user",'MYHASHDATA');
    $xmlapi->set_output('json');
    $xmlapi->set_debug(1);
    $res = $xmlapi->api2_query($account, "Email", "listpops");
    print_r($res);
    
    I'm getting the following:

    Code:
    {"apiversion":"2","data":{"reason":"api call failed. Module name is required.","result":"0"},"type":"text"}
    
    Here is the error log:

    Code:
    [Wed Mar 03 13:24:06 2010] [error] [client IP] DATA: user=user&cpanel_xmlapi_module=Email&cpanel_xmlapi_func=listpops&cpanel_xmlapi_apiversion=2, referer: http://ip/test/
    
    Here is the version information:
    cPanel 11.25.0-R43473 - WHM 11.25.0 - X 3.9

    FWIW: This exact code (outside of set_output part) works fine and returns a simplexml object.
     
  2. cPanelDavidN

    cPanelDavidN Integration Developer
    Staff Member

    Joined:
    Dec 17, 2009
    Messages:
    571
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    JSON output from api2 calls

    Howdy netrix37,

    You're following the documentation to the 'T'; I've been able to reproduce this as well with some other api2 calls.

    Like you said, it's only with JSON, XML return requests work as expected.

    I'll have to research this further to verify that the documentation is correct for JSON calls. If the docs are right, then this may be a bug.

    will get back asap; thanks for your patience!

    Regards,
    -DavidN
     
  3. 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
    David kindly let me know about the issue you were having. This was due to an issue in the XMLAPI Class where had "cpanel_xmlapi_*" hard coded into the api1 & api2 query functions. I have gone ahead and patched this issue in v1.0.5 and you can download it at: http://sdk.cpanel.net/lib/xmlapi/php/cp_xmlapi_php_v1.0.5.tar.gz

    Now it will use 'cpanel_jsonapi_*' for querying if the output type is 'json'.
     
  4. cPanelDavidN

    cPanelDavidN Integration Developer
    Staff Member

    Joined:
    Dec 17, 2009
    Messages:
    571
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
Loading...

Share This Page