(Jun 22) Release 0.9.8-19 with bug fixes available now. Run this command for update v-update-sys-vesta-all

Error 4 adding (unexisting) domain with v-add-domain

Questions regarding the API
Application Programming Interface
Forum rules
Before creating a new topic or reply on the forum you should fill out additional fields "Os" and "Web" in your profile section.
In case of violation, the topic can be closed or response from the support will not be received.
willowmagrini
Posts: 3
Joined: Fri Aug 25, 2017 1:10 pm

Os: Ubuntu 16x
Web: apache + nginx

Error 4 adding (unexisting) domain with v-add-domain

Postby willowmagrini » Fri Aug 25, 2017 1:48 pm

Hello,
I´m trying to create a domain with PHP following this guide: https://vestacp.com/docs/api/#add_domain .
In my website I ´ve created a form to fill the data and send it to the script above.

I´m getting "Query returned error code: 4" even when the domain doesn't exists.
Vesta is creating Web/DNS/Mail but returning Error.
Anybody had that yet?
thanks

My function:

Code: Select all

function cria_web($user,$endereco){
 $vst_hostname = 'xxxxxxxx';
 $vst_username = 'xxxxxxxx';
 $vst_password = 'xxxxxxxx;
 $vst_returncode = 'yes';
 $vst_command = 'v-add-domain';

 // New Domain
 // Prepare POST query
 $postvars = array(
     'user' => $vst_username,
     'password' => $vst_password,
     'returncode' => $vst_returncode,
     'cmd' => $vst_command,
     'arg1' => $user,
     'arg2' => $endereco
 );
 $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";
 }
}

Return to “Scripting / API”



Who is online

Users browsing this forum: No registered users and 1 guest

cron