[SOLVED] API: create snapshot via Python

Jun 29, 2023
3
0
6
Hi,

I've came up with a working Python script to get all snapshots for specific VMs.

This is the snippet to GET all snapshots for a certain VM (working!):
Python:
api_node = proxmox_api + "/json/nodes/" + proxmox_node + "/qemu/" + node_id + "/snapshot"
proxmox_api_auth = "PVEAPIToken=" + proxmox_apikey_owner + "!" + "snapshot=" + proxmox_apikey

headers = {
    'Content-Type': 'application/json',
    'Authorization': proxmox_api_auth,
}

api_response = requests.get(api_node, headers=headers, verify=False)

If I add the following to CREATE a snapshot, I get an error 500 (YES, snapname is certainly a string):
Python:
data = {
    'snapname': next_snapshot_name,
}

api_response = requests.post(api_node, headers=headers, data=data, verify=False)

Can you tell me what I'm missing? Thanks for your time, have a nice day!