dzVents asynchronous HTTP DELETE request

Easy to use, 100% Lua-based event scripting framework.
Post Reply
MikeF
Posts: 248
Joined: Sunday 19 April 2015 0:36
Target OS: Raspberry Pi
Domoticz version: V4.9700
Location: UK
Contact:

dzVents asynchronous HTTP DELETE request

Post by MikeF » Wednesday 05 December 2018 13:42

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: 1376
Joined: Tuesday 03 January 2017 15:18
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Netherlands
Contact:

Re: dzVents asynchronous HTTP DELETE request

Post by waaren » Wednesday 05 December 2018 14:36

MikeF wrote:
Wednesday 05 December 2018 13: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) 
Raspberry (debian stretch via berryboot on Synology DS916+) , Domoticz (almost) latest Beta, , dzVents 2.6, RFLink, RFXtrx433e, P1, Youless, Harmony, Hue, Yeelight, Xiaomi, HomeWizard, Zwave, Amazon echo

MikeF
Posts: 248
Joined: Sunday 19 April 2015 0:36
Target OS: Raspberry Pi
Domoticz version: V4.9700
Location: UK
Contact:

Re: dzVents asynchronous HTTP DELETE request

Post by MikeF » Wednesday 05 December 2018 14:45

Thanks (was hoping to avoid curl!)

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest