Skip to main content

{"cpanelresult":{"apiversion":"2","error":"Access denied","data":{"reason":"Access denied","result":"0"},"type":"text"}}

Comments

3 comments

  • cPanelTJ
    Hi @Matt Paplham , I'm not seeing any issues with API Token authorization on my end. I've tested it for creating an account and list accounts through Perl, PHP, and curl. You said you tried an API token that you know works from command line; is that using curl with the same createacct endpoint? Do the servers that you are testing on have a registered SSL certificate? If not, you'll need CURLOPT_SSL_VERIFYHOST,0
    in your header of your PHP code and --insecure
    in your curl over CLI.
    0
  • Matt Paplham
    Thanks for your response. I appreciate your time. From the command line, I am using the same endpoint, yes. And yes, our servers have a registered SSL certificate. With a fresh mind this morning I have figured out it is something with how I've set up the variables. If I set the curl options using no variables, it works just fine.
    0
  • Matt Paplham
    I changed the following and it worked: [CODE=php] $url = $this->server_address.':2087/json-api/createacct?api.version=1&username='.$this->cp_user.'&domain='.$this->domain.'&contactemail='.$this->email.'&dkim=1&frontpage=0&hasshell=1&language=en&owner=root&mxcheck=auto&owner=root&password='.$this->password.'&plan=Inception'; $header[0] = 'Authorization: whm root:'.$this->server_auth;
    I'm fairly new to PHP, but I thought either way would work. At any rate, thanks for all your help.
    0

Please sign in to leave a comment.