I am trying to create a VM via the API and keep getting invalid format. The authentication appears to be working but not the creation of the VM. I am on Proxmox VE 9.1.2, running on a mini pc and am connecting via WSL - Ubuntu. could you please help me thanks, Reg
Here is my script:
And here is the message I get:
Here is my script:
Bash:
#!/bin/bash
# Variables
PROXMOX_HOST="my ip"
USERNAME="root@pam"
# Prompt for password securely
read -sp 'Enter Proxmox password: ' PASSWORD
echo
# Authenticate and get JSON response
RESPONSE=$(curl -sk -d "username=$USERNAME&password=$PASSWORD" \
-X POST https://$PROXMOX_HOST:8006/api2/json/access/ticket)
# Extract ticket and CSRF token using jq
TICKET=$(echo "$RESPONSE" | jq -r '.data.ticket')
CSRF_TOKEN=$(echo "$RESPONSE" | jq -r '.data.CSRFPreventionToken')
# Check if authentication succeeded
if [ "$TICKET" == "null" ] || [ -z "$TICKET" ]; then
echo "Authentication failed. Check your credentials."
exit 1
fi
# Use ticket to list nodes
curl -sk -b "PVEAuthCookie=$TICKET" https://$PROXMOX_HOST:8006/api2/json/nodes
# Variables for VM creation
NODE="homeserver"
VMID=200
VMNAME="linux-playground"
MEMORY=2048
CORES=2
ISO_IMAGE="local:iso/ubuntu-22.04.3.iso"
DISK_STORAGE="local-lvm"
DISK_SIZE=32
# Create VM via API - no disk or ISO
curl -sk -b "PVEAuthCookie=$TICKET" \
-H "CSRFPreventionToken: $CSRF_TOKEN" \
-X POST https://$PROXMOX_HOST:8006/api2/json/nodes/$NODE/qemu \
-d "vmid=$VMID" \
-d "name=$VMNAME" \
-d "memory=$MEMORY" \
-d "cores=$CORES" \
-d "net0=e1000,bridge=vmbr0" \
-d "ide2=local:iso/ubuntu-24.04.3.iso,media=cdrom" \
-d "virtio0=local-lvm:$DISK_SIZE" \
-d "boot=cd" \
-d "agent=1"
And here is the message I get:
Bash:
linux_playground2.sh
Enter Proxmox password:
{"data":[{"status":"online","node":"homeserver","uptime":385420,"maxmem":33060659200,"id":"node/homeserver","maxcpu":16,"mem":22946234368,"disk":21445115904,"maxdisk":100861726720,"level":"","cpu":0.0432401451951856,"ssl_fingerprint":"11:E0:6A:42:0B:2D:69:A7:AD:13:B7:09:09:6A:8B:F8:35:42:60:AD:7C:20:45:D8:DF:E1:C1:E8:6D:12:09:8A","type":"node"}]}{"data":null,"errors":{"ide2":"invalid format - duplicate key in comma-separated list property: file\n","net0":"invalid format - duplicate key in comma-separated list property: model\n"},"message":"Parameter verification failed.\n"