[SOLVED] lxc config via api (PUT problem)

g0ha

Active Member
Jan 11, 2019
25
4
43
38
Hi! Stuck on trying to change lxc config via api, example:
curl -Ss --insecure -X PUT --header 'Authorization: PVEAPIToken=root@pam!test=UUID' --data-urlencode onboot=1 "https://pve1:8006/api2/json/nodes/pve1/lxc/107/config"|jq '.' { "data": null }
Problem only with this PUT method, other POST or GET works fine.
Via pvesh all works fine.
Other PUT like:
curl -Ss --insecure -X PUT --header 'Authorization: PVEAPIToken=root@pam!test=UUID' --data-urlencode disk="scsi0" --data-urlencode size="5G" "https://$pve1:8006/api2/json/nodes/pve1/qemu/ID/resize"
works fine too.
 
add '-v' to the curl command line to see more?
 
curl -v --insecure -X PUT --header 'Authorization: PVEAPIToken=root@pam!test=UUID' -d onboot=1 "https://pve1:8006/api2/json/nodes/pve1/lxc/107/config" * Trying 10.1.1.1... * TCP_NODELAY set * Connected to pve1 (10.1.1.1) port 8006 (#0) * ALPN, offering h2 * ALPN, offering http/1.1 * successfully set certificate verify locations: * CAfile: /etc/ssl/certs/ca-certificates.crt CApath: /etc/ssl/certs * TLSv1.3 (OUT), TLS handshake, Client hello (1): * TLSv1.3 (IN), TLS handshake, Server hello (2): * TLSv1.3 (IN), TLS Unknown, Certificate Status (22): * TLSv1.3 (IN), TLS handshake, Unknown (8): * TLSv1.3 (IN), TLS Unknown, Certificate Status (22): * TLSv1.3 (IN), TLS handshake, Certificate (11): * TLSv1.3 (IN), TLS Unknown, Certificate Status (22): * TLSv1.3 (IN), TLS handshake, CERT verify (15): * TLSv1.3 (IN), TLS Unknown, Certificate Status (22): * TLSv1.3 (IN), TLS handshake, Finished (20): * TLSv1.3 (OUT), TLS change cipher, Client hello (1): * TLSv1.3 (OUT), TLS Unknown, Certificate Status (22): * TLSv1.3 (OUT), TLS handshake, Finished (20): * SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384 * ALPN, server did not agree to a protocol * Server certificate: * subject: OU=PVE Cluster Node; O=Proxmox Virtual Environment; CN=pve1 * start date: Feb 26 15:39:32 2020 GMT * expire date: Feb 25 15:39:32 2022 GMT * issuer: CN=Proxmox Virtual Environment; OU=OU; O=PVE Cluster Manager CA * SSL certificate verify result: unable to get local issuer certificate (20), continuing anyway. * TLSv1.3 (OUT), TLS Unknown, Unknown (23): > PUT /api2/json/nodes/pve1/lxc/107/config HTTP/1.1 > Host: pve1:8006 > User-Agent: curl/7.58.0 > Accept: */* > Authorization: PVEAPIToken=root@pam!test=UUID > Content-Length: 8 > Content-Type: application/x-www-form-urlencoded > * upload completely sent off: 8 out of 8 bytes * TLSv1.3 (IN), TLS Unknown, Certificate Status (22): * TLSv1.3 (IN), TLS handshake, Newsession Ticket (4): * TLSv1.3 (IN), TLS Unknown, Certificate Status (22): * TLSv1.3 (IN), TLS handshake, Newsession Ticket (4): * TLSv1.3 (IN), TLS Unknown, Unknown (23): < HTTP/1.1 200 OK < Cache-Control: max-age=0 < Connection: Keep-Alive < Connection: Keep-Alive < Date: Thu, 24 Sep 2020 07:21:32 GMT < Pragma: no-cache < Server: pve-api-daemon/3.0 < Content-Length: 13 < Content-Type: application/json;charset=UTF-8 < Expires: Thu, 24 Sep 2020 07:21:32 GMT < * Connection #0 to host pve1 left intact {"data":null}
 
ah sorry - PUT to config update has no return value!
 
nothing? you get back '200 OK' with no content -> your config change worked.
 
lol, ist blow my mind, tupically its return task ID, but there only null
 
for VMs, there is a POST config update API endpoint that runs in a task. for CTs this is not the case, since most changes should be instant (or post-poned to the next reboot of the container).
 

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!