[SOLVED] Start LXC using API?

Dunuin

Distinguished Member
Jun 30, 2020
14,793
4,630
258
Germany
Hi,

I want to start a LXC using the API but that isn't working and I can't see why. I'm probably just too stupid and missing something easy.
I created a token with admin privileges for testing.

With pvesh create /nodes/j3710/lxc/133/status/start I can start my LXC.

With curl -k -H 'Authorization: PVEAPIToken=root@pam!test=<mySecret>' https://192.168.43.40:8006/api2/json/nodes/j3710/lxc/133/status/current I can poll informations about the LXC so I guess authentification works fine.

But using curl -k -X Post -H 'Authorization: PVEAPIToken=root@pam!test=<mySecret>' https://192.168.43.40:8006/api2/json/nodes/j3710/lxc/133/status/start nothing happens. Command just finishes without any complains but the LXC won't start.

Someone with more API experience can give me a hint what I'm missing?
 
Hi,

curl/http is a bit sensible w.r.t. casing on HTTP methods, so try s/Post/POST/, i.e.:

curl -k -X POST -H 'Authorization: PVEAPIToken=root@pam!test=<mySecret>' https://192.168.43.40:8006/api2/json/nodes/j3710/lxc/133/status/start

That should then return the UPID of the start task. (might be possible that either we or curl should be a bit more telling here, maybe even error out)
 
Last edited:
  • Like
Reactions: Dunuin

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!