elcodeo
(Vince)
January 17, 2022, 11:27am
1
Hello,
I’m trying to deal with the REST API of “Proxmox” to start/stop virtual machines through openHAB. The state method works fine but the command method does not.
I already figured out what’s the reason for this issue:
The POST method always creates a string with the state value and inserts it into the request as “content”.
Excerpt from the log:
Sending to 'https://XYZ:8006/api2/..../status/shutdown': Method = {POST}, Headers = {Accept-Encoding: gzip, User-Agent: Jetty/9.4.43.v20210629, Content-Type: application/json, Authorization: PVEAPIToken=XXXX, Content = {shutdown}
The API endpoint can’t handle the content “{shutdown}”. So i need to send a POST request without any content. How can I realize this use case?
Greeting,
Vince
Can you post the configuration of your Thing and Channel, and also the Item linked to it?
elcodeo
(Vince)
January 17, 2022, 2:17pm
3
Thing & Channel:
UID: http:url:proxmoxPVE
label: Proxmox Server
thingTypeUID: http:url
configuration:
authMode: BASIC
headers:
- Authorization=PVEAPIToken=XXXXX
ignoreSSLErrors: true
baseURL: https://XYZ:8006/api2/json
delay: 0
stateMethod: GET
refresh: 30
commandMethod: POST
contentType: application/json
timeout: 3000
bufferSize: 2048
channels:
- id: lxc117
channelTypeUID: http:switch
label: LXC Server
description: ""
configuration:
onValue: running
commandTransformation: MAP:proxmox.map
offValue: stopped
stateExtension: /nodes/pve/lxc/117/status/current
commandExtension: /nodes/pve/lxc/117/status/%2$s
stateTransformation: JSONPATH:$.data.status
promox.map:
running=start
stopped=shutdown
The item is a “simple” switch.
Did you try to send commands using the get method ? I always use Firefox with RESTer to test what is the protocol and actual message format to use.
elcodeo
(Vince)
March 26, 2022, 8:38am
6
The API rejects start/stop commands by using the GET method. The POST method would work fine when the HTTP binding would send an empty “content”.
elcodeo
(Vince)
August 1, 2024, 7:49am
7
Unfortunately there is still no option in 4.2.0 to do a http (post) request by keeping the “content” empty.
Dear devoloper team, could you please extend the http binding with the option to keep the “content” empty for the “command” method?