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.

json-api/listaccts Access denied

Discussion in 'cPanel Developers' started by dpeschman, Sep 12, 2012.

  1. dpeschman

    dpeschman Registered

    Joined:
    Sep 12, 2012
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    DataCenter Provider
    I get Access denied calling json-api/listaccts w/ root on a fresh install. Is this because I haven't logged in and gone through the initial cPanel setup w/ a browser? If so, is there an API call to accomplish that?

    Code:
    <?php
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER,0);# Allow self-signed certs
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,0);# Allow certs that do not match the hostname
    curl_setopt($curl, CURLOPT_HEADER,0);# Do not include header in output
    curl_setopt($curl, CURLOPT_RETURNTRANSFER,1);# Return contents of transfer on curl_exec
    $username = "root";
    $password = "pw";
    $header[0] = 'Authorization: Basic ' . base64_encode($username.':'.$password) . "\n\r";
    curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
    $q = "https://192.168.32.198:2087/json-api/listaccts";
    curl_setopt($curl, CURLOPT_URL, $q);
    $r = curl_exec($curl);
    print $r;
    ?>
    
    Response:
    Code:
    (
        [cpanelresult] => stdClass Object
            (
                [apiversion] => 2
                [error] => Access denied
                [data] => stdClass Object
                    (
                        [reason] => Access denied
                        [result] => 0
                    )
    
                [type] => text
            )
    
    )
    
     
    #1 dpeschman, Sep 12, 2012
    Last edited: Sep 13, 2012
  2. dpeschman

    dpeschman Registered

    Joined:
    Sep 12, 2012
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    DataCenter Provider
    Please hold. I think I'm stupid.
     
  3. dpeschman

    dpeschman Registered

    Joined:
    Sep 12, 2012
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    DataCenter Provider
    Stupidity confirmed; please disregard.
     
Loading...

Share This Page