Trying to shutdown VM through API with curl

Feb 10, 2016
24
0
21
58
Hi!

I'm trying to shutdown a virtual machine with, but doesn't


With developer tools and API DOC reference i get this valuable info:

* DEV Tools
https://------:8006/api2/extjs/nodes/12345678HV1/qemu/2254/status/shutdown
Request Method:POST
Status Code:200 OK
Remote Address:------:8006
Referrer Policy:no-referrer-when-downgrade


* API

Shutdown virtual machine. This is similar to pressing the power button on a physical machine.This will send an ACPI event for the guest OS, which should then proceed to a clean shutdown.

USAGE
HTTP: POST /api2/json/nodes/{node}/qemu/{vmid}/status/shutdown

And required parameter as: node (String) and vmid (integer)

My curl call in bash is:

curl -s -X POST -k https://------:8006/api2/extjs/nodes/12345678HV1/qemu/2254/status/shutdown -b "PVEAuthCookie=$TOKEN"

but I get no response and the virtual machine doesn't shutdown.

Any ideas?

NOTE:
If the curl call is:
curl -s -k https://------:8006/api2/extjs/nodes/12345678HV1/qemu/2254/status/shutdown -b "PVEAuthCookie=$TOKEN"
I get a
{"message":"Method 'GET /nodes/12345678HV1/qemu/2254/status/shutdown' not implemented","status":501,"success":0,"data":null}
response
 
Hi,
Sorry for waking this thread up, but your problem is pretty clear, status "501" a.k.a. NOT IMPLEMENTED, because you're trying to do a GET request instead of a POST request.
Anyway, I'm pretty sure there is a better way to do this and not allowing anyone to call proxmox's API externally. A suggestion would be to run a VM that can do the call locally, and running a server on that VM to allow users to shutdown/startup, maybe also using authentication.