StamPLC | EZData | Web API Problem
-
Hello. I am experimenting with the remote web api features.
The web UI relay toggle buttons work OK but I cannot get the relays to update via the Advanced | Relays | Set http links. The GET status http links work, but the SET links throw an error. For example (I've hidden my device id in the link):
https://ezdata2.m5stack.com/api/v2/device/updateStamPlc/${device_id}/relay/1/true
throws the error:
{ "code": 500, "msg": "fail: Request method 'GET' not supported", "data": null }
Has anyone else reproduced this or have I missed something?
Also, is there no local Web API in the demo firmware to control relays?
Thank you.
-
I figured it out. I was simply clicking on the link which obviously is an HTTP GET request. Trying this in Chrome DevTools | Console works fine (note the "PUT" method):
fetch('https://ezdata2.m5stack.com/api/v2/device/updateStamPlc/${device_id}/relay/0/true', {method: "PUT"}) .then(res => res.json()) .then(console.log)
Result:
{code: 200, msg: 'OK', data: 1}