We are happy to announce that Vesta is back under active development as of 25 February 2024. We are working on v1 candidate and expect to engage more with the community over the coming months. We are committed to open source, and we encourage contributors to help us build the future of Vesta.
Trying to use API via Python, getting blank result
Trying to use API via Python, getting blank result
Ok, so I have tried this many ways, via URL directly, using username and password or API hash, and every time I try, I get a blank result.
Here is the latest attempt to get it to work:
I have tried it other ways and gotten nothing in return. Do you have to enable API? Is there a log I can check to see what error there was if there is one? (normally it is displayed on the screen, but nothing is in this case)
Here is the latest attempt to get it to work:
Code: Select all
import urllib2
import json
import os
vst_url = "https://myserver.com:8083/api/"
vst_hash = "my_really_long_hash_api_key"
vst_cmd = "v-list-users"
request = urllib2.Request(vst_url, headers={"hash":vst_hash, "cmd":vst_cmd, "returncode":"yes", "arg1":"json"})
result = json.load(urllib2.urlopen(request))
print result
Re: Trying to use API via Python, getting blank result
The odd thing... It works in PHP... but I cannot seem to emulate it in Python... anyone had any success?
Re: Trying to use API via Python, getting blank result
Ok, for all those wondering how to do it
I tried 50 different ways, and all of a sudden, this one worked.
There is NO documentation on this, Time for a Blog post.
Code: Select all
import requests
url = "https://srv1.serversmadeeasy.com:8083/api/index.php"
user = "admin"
password = "your-password-goes-here"
cmd = "v-list-user"
arg1 = "username"
arg2 = "json"
data = {'user':user, 'password':password, 'cmd':cmd, 'arg1':arg1, 'arg2':arg2}
resp = requests.post(url, data)
print resp.json()
There is NO documentation on this, Time for a Blog post.