ioBroker / ioBroker.simple-api

HTTP-API Interface to read and write objets and states
MIT License
41 stars 19 forks source link

"SET" works via Browser but not via Http.client #182

Closed tehmilcho closed 8 months ago

tehmilcho commented 8 months ago

Hey,

there maybe im just to stupid but cant figure it out...

I want to call the API from a "Fibrao Homecenter lite" via http.client, when i use "toggle" it works fine but i want to use "set" to make sure it gets the state that i want it failes with Error 500 and he cant find the object.

In Browser: http://SERVER:8087/set/0_userdata.0.VirtualDevices.hc3lite.FlurPIR-1?value=false

{ "id": "0_userdata.0.VirtualDevices.hc3lite.FlurPIR-1", "value": false, "val": false }

Via Script:

[24.11.2023] [17:02:45] [DEBUG] [SCENE29]: "error: no value found for \"0_userdata.0.VirtualDevices.hc3lite.FlurPIR-1\". Use /set/id?value=1 or /set/id?value=1&wait=1000"

The Script in the Home center is lua:

local url = 'http://SERVER:8087/set/0_userdata.0.VirtualDevices.hc3lite.FlurPIR-1?value=true' local selfhttp = net.HTTPClient({timeout=2000})

selfhttp:request(url, { options={ timeout = 5000 }, success = function(response) print(response.status) print(response.data) end, error = function(message) print("error:", message) end })

what do i wrong? The same code works fine with toggle as i said. In SimpleAPI Debug log will not nothing when the Error 500 happen.

tehmilcho commented 8 months ago

Found (with help of the iobroker forum), this lua script from the home center 3 lite had problems that in der url is an "?", I had to replace the "?" in the URL with "%3F" now it works fine.