Deploy VM with curl and Proxmox API

lince

Member
Apr 10, 2015
78
3
8
Hello,

I followed the instructions here to use the API:

https://pve.proxmox.com/wiki/Proxmox_VE_API

When I request information it works great but when I try to deploy a container it returns a 501 error.

This is the command I'm launching:

csrf="CSRFPreventionToken: 5746EF2E:AofYoEWNFDofTkzBfLX7YRcgepE";
curl -k -b `cat proxmox.cookie` -H "$csrf" -X PUT "https://192.168.x.x:8006/api2/json/nodes/pve3/lxc -vmid ${vmid} -hostname $hostname -storage nfs-ssd -password ${pass} -ostemplate nfs-usb:vztmpl/$template -memory 512 -swap 0 -disk 2 -cpus 1 -net0 name=eth0,bridge=vmbr0,ip=192.168.x.${vmid}/24,gw=192.168.x.x"

Here is the error:

192.168.x.x - - [26/May/2016:15:36:18 +0200] "PUT /api2/json/nodes/pve3/lxc -vmid 119 -hostname host.name -storage nfs-ssd -password password -ostemplate nfs-usb:vztmpl/ubuntu-14.04-x86_64-minimal.tar.gz -memory 512 -swap 0 -disk 2 -cpus 1 -net0 name=eth0,bridge=vmbr0,ip=192.168.x.x/24,gw=192.168.x.x HTTP/1.1" 501 -

I tried both with PUT and with PUSH and both return error 501. What is weird is that when I launch GET and I check the log, I can see the username with this is not shown in the log for PUT and PUSH. See here:

192.168.x.x - root@pam [26/May/2016:15:27:05 +0200] "GET /api2/json/cluster/nextid HTTP/1.1" 200 14

To get the cookie I launched a request to https://192.168.x.x:8006/api2/json/access/ticket and then from the response, I got both the cookie and the CSRF. Is this correct or do I have to get the CSRF in a different way ?

Thanks for your help.
 
Last edited:
  • Like
Reactions: lince
Thanks, it worked :)


192.168.x.x - root@pam [27/May/2016:22:09:20 +0200] "POST /api2/json/nodes/pve3/lxc HTTP/1.1" 200 70
 

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!