API error: 506 upload 'Content-Type 'application/json' not implemented

crash.ntech

Active Member
Dec 2, 2017
17
2
43
35
I'm trying to create qemu from api and I get error from header.

This works on proxmox 7, but error in proxmox 6.

Reproduce:
Code:
curl -X POST -H 'Content-Type: application/json' -H 'Authorization: PVEAPIToken=root@pam!test=...' -v -d '{"node":"c5n1","vmid":101,"filename":"vm-101-disk-0","size":"32G","storage":"local-lvm"}' https://192.168.0.1:8006/api2/json/nodes/c5n1/storage/local-lvm/content
 
The API you are using does not "create qemu" but rather a disk for a specified VM.
You are specifying too many things as data. One thing to keep in mind when you are consulting PVE API viewer is that listed "required parameters" refer both to URI path and the extra params.
In your case the node and storage are already in URI.

"pvesh" is a great tool to troubleshoot your API work:
PVE6:
Code:
root@proxmox-1:~#  pvesh create nodes/proxmox-1/storage/bbnas/content -vmid 101 -size 32G -filename vm-101-disk-0.raw
Formatting '/mnt/pve/bbnas/images/101/vm-101-disk-0.raw', fmt=raw size=34359738368
bbnas:101/vm-101-disk-0.raw
root@proxmox-1:~#  pvesh create nodes/proxmox-1/storage/bbnas/content -vmid 101 -size 32G -filename  vm-101-disk-0.raw -storage local
Unknown option: storage
400 unable to parse option
pvesh create <api_path> --filename <string> --size <string> --vmid <integer> [OPTIONS] [FORMAT_OPTIONS]

PVE7:
[CODE]root@proxmox7-nvme1:~# pvesh create nodes/proxmox-1/storage/bbnas/content -vmid 101 -size 32G -filename vm-102-disk-0.raw
Formatting '/mnt/pve/bbnas/images/101/vm-102-disk-0.raw', fmt=raw size=34359738368"bbnas:101/vm-102-disk-0.raw"
root@proxmox7-nvme1:~# pvesh create nodes/proxmox-1/storage/bbnas/content -vmid 101 -size 32G -filename  vm-104-disk-0 -storage local
Unknown option: storage
400 unable to parse option
pvesh create <api_path> --filename <string> --size <string> --vmid <integer> [OPTIONS] [FORMAT_OPTIONS]


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
 
Last edited:
The API you are using does not "create qemu" but rather a disk for a specified VM.
You are specifying too many things as data. One thing to keep in mind when you are consulting PVE API viewer is that listed "required parameters" refer both to URI path and the extra params.
In your case the node and storage are already in URI.

"pvesh" is a great tool to troubleshoot your API work:
PVE6:
Code:
root@proxmox-1:~#  pvesh create nodes/proxmox-1/storage/bbnas/content -vmid 101 -size 32G -filename vm-101-disk-0.raw
Formatting '/mnt/pve/bbnas/images/101/vm-101-disk-0.raw', fmt=raw size=34359738368
bbnas:101/vm-101-disk-0.raw
root@proxmox-1:~#  pvesh create nodes/proxmox-1/storage/bbnas/content -vmid 101 -size 32G -filename  vm-101-disk-0.raw -storage local
Unknown option: storage
400 unable to parse option
pvesh create <api_path> --filename <string> --size <string> --vmid <integer> [OPTIONS] [FORMAT_OPTIONS]

PVE7:
[CODE]root@proxmox7-nvme1:~# pvesh create nodes/proxmox-1/storage/bbnas/content -vmid 101 -size 32G -filename vm-102-disk-0.raw
Formatting '/mnt/pve/bbnas/images/101/vm-102-disk-0.raw', fmt=raw size=34359738368"bbnas:101/vm-102-disk-0.raw"
root@proxmox7-nvme1:~# pvesh create nodes/proxmox-1/storage/bbnas/content -vmid 101 -size 32G -filename  vm-104-disk-0 -storage local
Unknown option: storage
400 unable to parse option
pvesh create <api_path> --filename <string> --size <string> --vmid <integer> [OPTIONS] [FORMAT_OPTIONS]


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
Thank for reply, I'm developing kuberentes operator for manage proxmox vms, and I need to use native api.
And without node and storage I got same error.
Code:
{"vmid":101,"filename":"vm-101-disk-0","size":"32G"}
 
I think you need to specify raw or qcow:
Code:
root@proxmox7-nvme1:~# pvesh create nodes/proxmox-1/storage/bbnas/content -vmid 101 -size 32G -filename  vm-104-disk-0.qcow2
Formatting '/mnt/pve/bbnas/images/101/vm-104-disk-0.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off preallocation=metadata compression_type=zlib size=34359738368 lazy_refcounts=off refcount_bits=16"bbnas:101/vm-104-disk-0.qcow2"


root@proxmox7-nvme1:~# pvesh create nodes/proxmox-1/storage/bbnas/content -vmid 101 -size 32G -filename  vm-105-disk-0
proxy handler failed: unable to parse volume filename 'vm-105-disk-0'


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
 
I think you need to specify raw or qcow:
Code:
root@proxmox7-nvme1:~# pvesh create nodes/proxmox-1/storage/bbnas/content -vmid 101 -size 32G -filename  vm-104-disk-0.qcow2
Formatting '/mnt/pve/bbnas/images/101/vm-104-disk-0.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off preallocation=metadata compression_type=zlib size=34359738368 lazy_refcounts=off refcount_bits=16"bbnas:101/vm-104-disk-0.qcow2"


root@proxmox7-nvme1:~# pvesh create nodes/proxmox-1/storage/bbnas/content -vmid 101 -size 32G -filename  vm-105-disk-0
proxy handler failed: unable to parse volume filename 'vm-105-disk-0'


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
Same error with format.
 
my mistake, you are using local-lvm, no extension needed.

I'll just say that this works fine for me on pve6:
Code:
curl --silent --insecure --data "username=root@pam&password=xxxxx" \
 https://localhost:8006/api2/json/access/ticket\
| jq -r '.data.ticket' | sed 's/^/PVEAuthCookie=/' > cookie
curl --silent --insecure --data "username=root@pam&password=xxxxx" \
 https://127.0.0.1:8006/api2/json/access/ticket \
| jq -r '.data.CSRFPreventionToken' | sed 's/^/CSRFPreventionToken:/' > csrftoken
curl --verbose --insecure  --cookie "$(<cookie)" --header "$(<csrftoken)" -X POST -H 'Content-Type: application/json' -d '{"vmid":101,"filename":"vm-101-disk6.raw","size":"1"}' https://127.0.0.1:8006/api2/json/nodes/proxmox-1/storage/local/content

Few things:
can you create disk via CLI? perhaps your storage is not marked to accept images?
can you create disk via pvesh?

keep in mind that PVE6 is EOL and EOS


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
 
my mistake, you are using local-lvm, no extension needed.

I'll just say that this works fine for me on pve6:
Code:
curl --silent --insecure --data "username=root@pam&password=xxxxx" \
 https://localhost:8006/api2/json/access/ticket\
| jq -r '.data.ticket' | sed 's/^/PVEAuthCookie=/' > cookie
curl --silent --insecure --data "username=root@pam&password=xxxxx" \
 https://127.0.0.1:8006/api2/json/access/ticket \
| jq -r '.data.CSRFPreventionToken' | sed 's/^/CSRFPreventionToken:/' > csrftoken
curl --verbose --insecure  --cookie "$(<cookie)" --header "$(<csrftoken)" -X POST -H 'Content-Type: application/json' -d '{"vmid":101,"filename":"vm-101-disk6.raw","size":"1"}' https://127.0.0.1:8006/api2/json/nodes/proxmox-1/storage/local/content

Few things:
can you create disk via CLI? perhaps your storage is not marked to accept images?
can you create disk via pvesh?

keep in mind that PVE6 is EOL and EOS


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
May be my problem with token auth, will test it.
 
my mistake, you are using local-lvm, no extension needed.

I'll just say that this works fine for me on pve6:
Code:
curl --silent --insecure --data "username=root@pam&password=xxxxx" \
 https://localhost:8006/api2/json/access/ticket\
| jq -r '.data.ticket' | sed 's/^/PVEAuthCookie=/' > cookie
curl --silent --insecure --data "username=root@pam&password=xxxxx" \
 https://127.0.0.1:8006/api2/json/access/ticket \
| jq -r '.data.CSRFPreventionToken' | sed 's/^/CSRFPreventionToken:/' > csrftoken
curl --verbose --insecure  --cookie "$(<cookie)" --header "$(<csrftoken)" -X POST -H 'Content-Type: application/json' -d '{"vmid":101,"filename":"vm-101-disk6.raw","size":"1"}' https://127.0.0.1:8006/api2/json/nodes/proxmox-1/storage/local/content

Few things:
can you create disk via CLI? perhaps your storage is not marked to accept images?
can you create disk via pvesh?

keep in mind that PVE6 is EOL and EOS


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
Which version of PVE 6 you are testing?