Page 1 of 1

dzVents asynchronous HTTP DELETE request

Posted: Wednesday 05 December 2018 12:42
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)

Re: dzVents asynchronous HTTP DELETE request

Posted: Wednesday 05 December 2018 13:36
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) 

Re: dzVents asynchronous HTTP DELETE request

Posted: Wednesday 05 December 2018 13:45
by MikeF
Thanks (was hoping to avoid curl!)