Vesta Control Panel - Forum

Community Forum

Skip to content

Advanced search
  • Quick links
    • Main site
    • Github repo
    • Google Search
  • FAQ
  • Login
  • Register
  • Board index Main Section General Discussion Debian/Ubuntu
  • Search

Admin API Problems

Debian/Ubuntu related topics
Locked
  • Print view
Advanced search
6 posts • Page 1 of 1
Graham
Posts: 57
Joined: Wed Sep 25, 2013 6:32 pm

Admin API Problems

Post by Graham » Fri Oct 18, 2013 1:22 pm

skid wrote:Admin API 100% ready and available via http. Use POST as request method. Here are some useful examples

Code: Select all

# Crete new user account "demo"
https://server-ip:8083/api/?&user=admin&password=currentpwd&cmd=v-add-domain&arg1=demo&arg2=d3m0p4ssw0rd&[email protected]

# Add domain demo.vestacp.com
https://server-ip:8083/api/?&user=admin&password=currentpwd&cmd=v-add-domain&arg1=demo&arg2=demo.vestacp.com
Hi All,

When I try to do anything via a post request to the API I'm getting a pretty empty HTTP 200 response back from the server.
Just tried this one:

Code: Select all

https://x.x.x.x:8083/api/?&user=admin&password=makeyuppey&cmd=v-add-domain&arg1=graham&arg2=wpcp.graham.pw&arg3=146.185.129.249
Anybody got this working yet or have any suggestions?

Thanks
Top

skid
VestaCP Team
Posts: 1476
Joined: Wed Apr 06, 2011 11:12 pm

Re: Admin API Problems

Post by skid » Fri Oct 18, 2013 3:14 pm

Try to play with following code


Here is an example for user listing which sho

Code: Select all

<?php

// Server credentials
$server = 'your-server.vestacp.com';
$user = 'admin';
$password = '1 slice of pizza!';


// Prepare variables
$postvars = array(
  'user' => $user,
  'password' => $password,
  'cmd' => 'v-list-users',
  'arg1' => 'json'
);
$postdata = http_build_query($postvars);


// Get current status
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://' . $server . ':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);

$results = json_decode($answer, true);
print_r($results);

?>

If you want to parse result instead of output then add returncode=yes to your request

Code: Select all

<?php

// Server credentials
$server = 'your-server.vestacp.com';
$user = 'admin';
$password = '1 slice of pizza!';


// Prepare variables
$postvars = array(
  'user' => $user,
  'password' => $password,
  'cmd' => 'v-delete-user',
  'arg1' => 'admin',
  'returncode' => 'yes'
);
$postdata = http_build_query($postvars);


// Get current status
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://' . $server . ':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);

if ($answer != 0) {
    echo "Command failed";
} else {
    echo "Command succeed";
}

?>
Top

Graham
Posts: 57
Joined: Wed Sep 25, 2013 6:32 pm

Re: Admin API Problems

Post by Graham » Fri Oct 18, 2013 3:58 pm

Perfect, thanks skid.
Top

sirpros
Posts: 13
Joined: Mon Oct 21, 2013 8:29 am

Re: Admin API Problems

Post by sirpros » Tue Feb 11, 2014 11:34 pm

hello,
I tried using the API and I've been able to successfully get two commands to work.
Please what are the other possible commands and how are their postvars know ?
I'll like to know if I can do email creation, creation of ftp account, and setting of MX records from the API.
Thanks in advance.
Top

Graham
Posts: 57
Joined: Wed Sep 25, 2013 6:32 pm

Re: Admin API Problems

Post by Graham » Tue Feb 11, 2014 11:48 pm

sirpros wrote:hello,
I tried using the API and I've been able to successfully get two commands to work.
Please what are the other possible commands and how are their postvars know ?
I'll like to know if I can do email creation, creation of ftp account, and setting of MX records from the API.
Thanks in advance.
They're all shown here, you can open each one to check the params

https://github.com/serghey-rodin/vesta/tree/master/bin
Top

sirpros
Posts: 13
Joined: Mon Oct 21, 2013 8:29 am

Re: Admin API Problems

Post by sirpros » Wed Feb 12, 2014 9:06 am

Thanks a lot.
Sergey is the man....always been.
Top


Locked
  • Print view

6 posts • Page 1 of 1

Return to “Debian/Ubuntu”



  • Board index
  • All times are UTC
  • Delete all board cookies
  • The team
Powered by phpBB® Forum Software © phpBB Limited
*Original Author: Brad Veryard
*Updated to 3.2 by MannixMD
 

 

Login  •  Register

I forgot my password