Closed MrKampf closed 6 years ago
The post method exists, it's just called create
.
So in your case, it would look like this:
$proxmox->create('/nodes/'.$node.'/lxc/'.$ProductVServerLXCAction->VServerProduct[$ProductVServerLXCAction->ProductID]['containerid'].'/status/stop',array());
Take a look at the Wiki for more info: https://github.com/ZzAntares/ProxmoxVE/wiki/Creating-resources
Yes, please do what @madmath03 suggest. Functions are named:
create
for POST
.get
for GET
.set
for PUT
.delete
for DELETE
.It was done this way to preserve consistency with the pvesh CLI Tool commands.
Feel free to re-open if the problem persist 👍
Sorry, because it's not work :/ http://prntscr.com/jauyi8 This is my Code. The "new Proxmox" work, by the function loading information i become information becaus stop dont work (Login with root user) http://prntscr.com/jauz7n Login data Loading work
Now http://prntscr.com/jauzhz i dont become true back and the server stop not. equal is this by start. The type is LXC Proxmox version is "Virtual Environment 5.1-41"
Thanks for all answers and sorry for my bad english
Ok, can you share what is the error you're getting back? what's the exception message if any? I don't see problems in you code, have you tried to send it a non-existent container ID so you can assure the call is being made and that you should get an error back?
Remember when there's an error you should get the errors
key in the response array, inspect that:
// Create a new proxmox user
$result = $proxmox->create('/access/users', $newUserData);
// If an error occurred the 'errors' key will exist in the response array
if (isset($result['errors'])) {
error_log('Unable to create new proxmox user.');
foreach ($result['errors'] as $title => $description) {
error_log($title . ': ' . $description);
}
} else {
echo 'Successful user creation!';
}
You can read more about that in the wiki.
You should also consider whether the user credentials you're using have the required permissions.
You can also pass your own HTTP Client as a third parameter to the Proxmox
class constructor and the library will use that client to make the calls to your server, this is useful because you can add a logger to your http client (like this).
It could also mean that your container has a lock, have you tried the same command using the PVESH CLI, there's many things it could be happening but you need to debug so that we have more info on why this happens.
I'm sorry if this is too much information, but without any logs, errors, exceptions there's no way I could now what's happening. 😄
Hello,
thanks for answer, because i dont become a error, thats the Problem, the LXC Server dont stop, the API say me he stoppt because they dont stoppt. Is see too no code error.
if($_GET['action']=="stop"){
$proxmox = new Proxmox($credentials);
$result = $proxmox->create('/nodes/Prx1/lxc/'.$ProductVServerLXCAction->VServerProduct[$ProductVServerLXCAction->ProductID]['containerid'].'/status/stop',array());
// If an error occurred the 'errors' key will exist in the response array
var_dump($result);
if (isset($result['errors'])) {
error_log('Unable to create new proxmox user.');
foreach ($result['errors'] as $title => $description) {
error_log($title . ': ' . $description);
}
} else {
echo 'Successful server stop!';
}
}
Answer from code: array(1) { ["data"]=> NULL } Successful server stop!null
The Server isn't stoppt... I dont finde the Problem.
I have found the error, i cant build string in class variable now:
$proxmox = new Proxmox($credentials);
$link='/nodes/Prx1/lxc/'.$ProductVServerLXCAction>VServerProduct[$ProductVServerLXCAction>ProduktID]['containerid'].'/status/stop';
$result = $proxmox->create($link);
Ok, so we can close the issue now that you've found the error, right?
Closing due to inactivity.
Hello,
i use your API, because i need the Post method. Thats not exist :/.
$proxmox->set('/nodes/'.$node.'/lxc/'.$ProductVServerLXCAction->VServerProduct[$ProductVServerLXCAction->ProductID]['containerid'].'/status/stop',array());
I want start and stop Vserver because i need post. Can you add this? Or give it a other function for this?