POST 501 Not Implemented (GET API calls working, POST not)

lubr

New Member
May 13, 2024
14
1
3
Hi.

My client is using Proxmox VE 8.1.4. Currently, I have been in webapp development using Proxmox API to maintain cluster/nodes/qemus. I am authenticated via API Token of PVE user but I tried PVE username/password with ticket/cookie/CSRF prevention as well and following behaves the same: when calling eg. POST /api2/json/nodes/NODE-01/qemu/103/status/stop HTTP/1.1 via API, it always ends with 501 Not Implemented. Besides that, all GET methods are working with no problems.

When I check log in /var/logs/pveproxy/pveproxy.log to be sure POST is not translated to GET for some reason, it looks like this: "POST /api2/json/nodes/NODE-01/qemu/103/status/stop HTTP/1.1" 501- as you can see, it results in 501 again.

But when I stop QEMU via Proxmox GUI, it looks as follows: "POST /api2/extjs/nodes/NODE-01/qemu/103/status/stop HTTP/1.1" 200

So I tried to set extjs as response type in my app and it ended lik this: "POST /api2/extjs/nodes/NODE-01/qemu/103/status/stop HTTP/1.1" 501 which means the same request ends different when called from different sources.

I have checked permissions, tried PAM as well. Nothing seems wrong. Do you have any idea, what needs to be set or checked? Is there any more detailed log to understand what is wrong and why?

Thx in advance.
 
Seems I have found the issue. It is related to (on Proxmox website recommended) https://github.com/Corsinvest/cv4pve-api-php library I am using. It encodes and sets content type for PUT and POST calls to JSON. When I use x-www-form-urlencoded via cURL instead of JSON for POST data, it goes through with 200 OK.

I was wondering why this lib works this way when, based on https://pve.proxmox.com/wiki/Proxmox_VE_API#API_URL section, JSON for PUT and POST is not supported (not mentioned). Or is there any option on Proxmox itself to set? Do you have any idea how to deal with this?