[SOLVED] Start LXC using API?

Dunuin

Distinguished Member
Jun 30, 2020
14,796
4,779
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