Control Web Panel

WebPanel => CentOS-WebPanel Bugs => Topic started by: trcosta on June 29, 2018, 05:35:34 PM

Title: API Problem when creating account
Post by: trcosta on June 29, 2018, 05:35:34 PM
When I try to add acount via api I get mysql errors.

(https://plus.google.com/u/0/photos/albums/p7pt2h5f8gvjicrjku5p302ruvlfcgdkc?pid=6572552793766851938&oid=102187499680484591753)
Title: Re: API Problem when creating account
Post by: josemnunez on June 29, 2018, 07:37:36 PM
Can you show the errors thrown at you?
Title: Re: API Problem when creating account
Post by: trcosta on June 30, 2018, 11:11:02 AM
Sorry, the image did not appeear.

Here is the image with the error:
(https://imageshack.com/a/img921/3523/krcIGJ.png)
Title: Re: API Problem when creating account
Post by: josemnunez on June 30, 2018, 11:22:51 AM
You could put here an example of the code that you are using for the invocation of the Api
Title: Re: API Problem when creating account
Post by: trcosta on June 30, 2018, 12:21:22 PM
I just changed the key below...
The user is in /etc/passwd after run the code, even with error messages shown in figure. I can connect to ftp using the user, but the user is not listed in cwp accounts in "list accounts".

<?php
$data = array(
"key" => 'mykey',
"action"=>'add',
"domain"=>'valiati5.com.br',
"user"=>'valiati5',
"pass"=>'32165487Ds821',
"email"=>'daniels@valiati5.com.br',
"package"=>'default',
"inode"=>0,
"limit_nproc"=>40,
"limit_nofile"=>100,
"server_ips"=>'177.53.142.39'
);

$url = "https://177.53.142.39:2304/v1/account";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");

curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

curl_setopt ($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt ($ch, CURLOPT_POST, 1);
$response = curl_exec($ch);
curl_close($ch);


echo '<pre>';
print_r($response);
echo '</pre>';
Title: Re: API Problem when creating account
Post by: josemnunez on June 30, 2018, 12:36:59 PM
Change "package" => 'default', for "package" => 1,
Title: Re: API Problem when creating account
Post by: trcosta on July 02, 2018, 02:35:36 AM
I will try tomorrow and post results here  :)
Title: Re: API Problem when creating account
Post by: trcosta on July 02, 2018, 04:50:24 PM
It is ok, solved.
Thanks.