WHM API RELATED - Permission Denied by using createacct command

SandeepDiL

Registered
Feb 2, 2015
1
0
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&[email protected]&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($curl, CURLOPT_SSL_VERIFYHOST,0);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER,0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER,1);
  
$header[0] = "Authorization: WHM $whmusername:" . preg_replace("'(\r|\n)'","",$hash);
curl_setopt($curl,CURLOPT_HTTPHEADER,$header);
curl_setopt($curl, CURLOPT_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
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,261
463
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.