API Bugs add new domain
-
- Posts: 21
- Joined: Thu Jun 04, 2015 9:22 am
API Bugs add new domain
Let me explain :
i have put vesta admin login details in vestacon.php and it is connecting fine.
I create a user rinkunn ok
And exampledo.com domain is not present.
I run this code:
Output:
Query returned error code: 4 ( i was expecting Domain has been successfuly created )
But this code has added this domain .
ok i reload this web page again:
Output:
Query returned error code: 4
So funny API :)
i have put vesta admin login details in vestacon.php and it is connecting fine.
I create a user rinkunn ok
And exampledo.com domain is not present.
I run this code:
Code: Select all
<?php
require("vestacon.php");
$vst_returncode = 'yes';
$vst_command = 'v-add-domain';
// New Domain
$username = "rinkunn";
$domain = "exampledo.com";
// Prepare POST query
$postvars = array(
'user' => $vst_username,
'password' => $vst_password,
'returncode' => $vst_returncode,
'cmd' => $vst_command,
'arg1' => $username,
'arg2' => $domain
);
$postdata = http_build_query($postvars);
// Send POST query via cURL
$postdata = http_build_query($postvars);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://' . $vst_hostname . ':8083/api/');
curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
$answer = curl_exec($curl);
// Check result
if($answer == 0) {
echo "Domain has been successfuly created\n";
} else {
echo "Query returned error code: " .$answer. "\n";
}
Output:
Query returned error code: 4 ( i was expecting Domain has been successfuly created )
But this code has added this domain .
ok i reload this web page again:
Output:
Query returned error code: 4
So funny API :)
-
- Collaborator
- Posts: 783
- Joined: Mon May 11, 2015 8:43 am
- Contact:
- Os: CentOS 6x
- Web: apache + nginx
Re: API Bugs add new domain
Try the same thing in the control panel. I think the domain you try to create already exists (error code 4: E_EXISTS - Object already exists).
-
- Posts: 21
- Joined: Thu Jun 04, 2015 9:22 am
Re: API Bugs add new domain
This code adding new domain but return wrong response. response it same in both case, in first case, it add domain successfully but return error response. and officially second response is error and it is right because domain is already present.
Re: API Bugs add new domain
I've run "v-add-domain" code from API help and recieved error code 2 - E_INVALID (Object or argument is not valid) and domain has not been added.
But when I've create POST query in the browser plugin - it was created successfuly.
Where is the bug?
But when I've create POST query in the browser plugin - it was created successfuly.
Where is the bug?
Code: Select all
<?php
// Server credentials
$vst_hostname = 'server.vestacp.com';
$vst_username = 'admin';
$vst_password = 'p4ssw0rd';
$vst_returncode = 'yes';
$vst_command = 'v-add-domain';
// New Domain
$username = 'demo';
$domain = 'demo.vestacp.com';
// Prepare POST query
$postvars = array(
'user' => $vst_username,
'password' => $vst_password,
'returncode' => $vst_returncode,
'cmd' => $vst_command,
'arg1' => $username,
'arg2' => $domain
);
$postdata = http_build_query($postvars);
// Send POST query via cURL
$postdata = http_build_query($postvars);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://' . $vst_hostname . ':8083/api/');
curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
$answer = curl_exec($curl);
// Check result
if($answer == 0) {
echo "Domain has been successfuly created\n";
} else {
echo "Query returned error code: " .$answer. "\n";
}
?>
Re: API Bugs add new domain
API documentation and examples:
http://vestacp.com/docs/API.pdf
CLI commands list and descriptions:
http://vestacp.com/docs/CLI.txt
-> viewtopic.php?f=18&t=12610
http://vestacp.com/docs/API.pdf
CLI commands list and descriptions:
http://vestacp.com/docs/CLI.txt
-> viewtopic.php?f=18&t=12610