dzVents asynchronous HTTP DELETE request

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
MikeF
Posts: 350
Joined: Sunday 19 April 2015 0:36
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.2
Location: UK
Contact:

dzVents asynchronous HTTP DELETE request

Post by MikeF »

Is it possible to do a DELETE HTTP request in dzVents (the wiki only refers to GET and POST)?

Logging out from the Hive website uses DELETE. In Python it looks like this:

Code: Select all

headers = {'Content-Type': 'application.json', 'Accept': 'application.json', \
	'X-AlertMe-Client': 'Hive Web Dashboard', 'Authorization': sessionId}
url = 'https://beekeeper-uk.hivehome.com/1.0/auth/logout'
r = requests.delete(url, headers=headers, verify=False)
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: dzVents asynchronous HTTP DELETE request

Post by waaren »

MikeF wrote: Wednesday 05 December 2018 12:42 Is it possible to do a DELETE HTTP request in dzVents (the wiki only refers to GET and POST)?
Not direct but should be possible to do this with an OS call to curl

Code: Select all

local curlExecutable        = "/usr/bin/curl"               -- Check if you have curl on your system

local function osExecute(cmd)
    local fileHandle     = assert(io.popen(cmd, 'r'))
    local commandOutput  = assert(fileHandle:read('*a'))
    local returnTable    = {fileHandle:close()}
    return commandOutput,returnTable[3]            -- rc[3] contains returnCode
end

local function callCurl(http)
    return osExecute(curlExecutable .. " -H 'Content-Type: application/json' -X DELETE " .. http)
end

domoticz.log(callCurl("https://beekeeper-uk.hivehome.com/1.0/auth/logout"),domoticz.LOG_FORCE) 
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
MikeF
Posts: 350
Joined: Sunday 19 April 2015 0:36
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.2
Location: UK
Contact:

Re: dzVents asynchronous HTTP DELETE request

Post by MikeF »

Thanks (was hoping to avoid curl!)
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest