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.
 

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!