![]() |
Bond Bridge API to LUA - Printable Version +- Logic Machine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8) +--- Thread: Bond Bridge API to LUA (/showthread.php?tid=4652) |
Bond Bridge API to LUA - BrentW - 16.03.2023 Hi All, Probably a simple one for most but could I get some assistance converting this curl function to Lua Code: curl -H "BOND-Token: f074b61f628018fd" -i http://192.100.0.61/v2/devices/79135791/actions/SetSpeed -X PUT -d "{\"argument\": 3}" [url=http://docs-local.appbond.com/#section/API-Concepts][/url]
Typically I am seeing the http request defaulting back to the GET function and not pushing the PUT.Thanks in advance RE: Bond Bridge API to LUA - BrentW - 16.03.2023 http = require("socket.http") ltn12 = require 'ltn12' json = require('json') http = require('socket.http') url = 'http://192.168.0.xxx/v2/devices/--Devide ID--/actions/Close' body = json.encode({ Close = { { argument = 'null', } } }) resp_Values = {} res, code, headers = http.request({ url = url, method = 'PUT', sink = ltn12.sink.table(resp_Values), source = ltn12.source.string(body), headers = { ['BOND-Token'] = 'b084cc33192220e', ['content-length'] = #body, ["Content-Type"] = "application/json"; } }) Code above works for the Bond Bridge for anyone interested. |