Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Member
    Join Date
    Jul 2006
    Posts
    14

    Default Cpanel XMLAPI 1.0.3 - JSON Output

    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. #2
    Integration Developer cPanelDavidN's Avatar
    Join Date
    Dec 2009
    Location
    Houston, TX
    Posts
    525

    Default 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
    David Neimeyer
    Integration Developer

    sdk.cpanel.net
    APIs: XML-API API1 & API2
    Check Out: Developer Downloads Integration Blog
    Need Support? Support Ticket Developer Forum Feature Request

  3. #3
    cPanel Staff cPanelMatt's Avatar
    Join Date
    Apr 2005
    Location
    Houston, TX
    Posts
    409

    Default

    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..._v1.0.5.tar.gz

    Now it will use 'cpanel_jsonapi_*' for querying if the output type is 'json'.
    Matt Dees
    Integration Developer
    cPanel, Inc.
    cPanel Integration Blog

  4. #4
    Integration Developer cPanelDavidN's Avatar
    Join Date
    Dec 2009
    Location
    Houston, TX
    Posts
    525

    Default JSON output from api2 calls using xmlapi.php

    For the record,

    The docs are, in fact, correct. I just over looked the details

    CallingAPIFunctions < AllDocumentation/AutomationIntegration < TWiki

    Regards,
    -DavidN
    David Neimeyer
    Integration Developer

    sdk.cpanel.net
    APIs: XML-API API1 & API2
    Check Out: Developer Downloads Integration Blog
    Need Support? Support Ticket Developer Forum Feature Request

Similar Threads & Tags
Similar threads

  1. Timeout errors for cPanel JSON-API requests
    By jdelsman in forum cPanel Developers
    Replies: 2
    Last Post: 11-30-2009, 08:36 PM
  2. Replies: 1
    Last Post: 11-24-2009, 03:42 PM
  3. cPanel XMLAPI - installssl
    By dpbuk in forum cPanel Developers
    Replies: 5
    Last Post: 06-01-2009, 05:34 AM
  4. XMLAPI support for CPanel
    By mberchtold in forum cPanel Developers
    Replies: 7
    Last Post: 04-02-2009, 03:50 PM
  5. Can not get xmlapi to work with cpanel functions.
    By anton_latvia in forum cPanel Developers
    Replies: 3
    Last Post: 11-15-2007, 11:13 AM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube