Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

WHM API RELATED - Permission Denied by using createacct command

Discussion in 'cPanel Developers' started by SandeepDiL, Feb 2, 2015.

  1. SandeepDiL

    SandeepDiL Registered

    Joined:
    Feb 2, 2015
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    DataCenter Provider
    Hello cP,

    Actually i'm working on a upcoming open source project written in Php to manned hosting/clients record. All other APIs are working super fine for me. But whenever I'm trying to execute "createacct" command, it show me Result : 0 with Reason : Permission Denied

    Here is a sample code that i'm using right now:

    PHP:
    <?php

    include 'config.php';

    $whmusername "root";
      
    # The contents of /root/.accesshash
    $hash $whmRemoteKey;
      
    $query "https://".$serverIP.":2087/json-api/createacct?api.version=1&username=ucfcoin&domain=example.com&plan=pack_SH-2&featurelist=default&quota=4000&password=12345luggage&ip=n&cgi=1&hasshell=0&contactemail=example@gmail.com&cpmod=x3&maxftp=unlimited&maxsql=10&maxpop=unlimited&maxlst=unlimited&maxsub=unlimited&maxpark=4&maxaddon=4&bwlimit=10000&language=en&useregns=0&hasuseregns=0&reseller=0&forcedns=1&mxcheck=local&MAX_EMAIL_PER_HOUR=500&MAX_DEFER_FAIL_PERCENTAGE=80";
      
    $curl curl_init();
    curl_setopt($curlCURLOPT_SSL_VERIFYHOST,0);
    curl_setopt($curlCURLOPT_SSL_VERIFYPEER,0);
    curl_setopt($curlCURLOPT_RETURNTRANSFER,1);
      
    $header[0] = "Authorization: WHM $whmusername:" preg_replace("'(\r|\n)'","",$hash);
    curl_setopt($curl,CURLOPT_HTTPHEADER,$header);
    curl_setopt($curlCURLOPT_URL$query);
      
    $result curl_exec($curl);
    if (
    $result == false) {
        
    error_log("curl_exec threw error \"" curl_error($curl) . "\" for $query");
    }
    curl_close($curl);
      
    print_r(json_decode($result,true));

    ?>

    AND
    Here is the output that i got:
    Code:
    Array ( [metadata] => Array ( [result] => 0 [reason] => Permission denied. [version] => 1 [command] => createacct ) ) 
    
    Can anyone point out the reason of that issue ??? Note: All other API commands are already tested and working fine....

    Thanks
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,367
    Likes Received:
    1,855
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello :)

    Do you experience any error messages when testing this API command via "WHM Home » Development » API Shell"? Do you notice any error messages in /usr/local/cpanel/logs/error_log (or login_log) when authentication fails?

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice