🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    StamPLC | EZData | Web API Problem

    PRODUCTS
    1
    2
    175
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C
      chirpychips
      last edited by

      Hello. I am experimenting with the remote web api features.

      PHOTO-2025-05-02-09-28-32.jpg

      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.

      C 1 Reply Last reply Reply Quote 0
      • C
        chirpychips @chirpychips
        last edited by chirpychips

        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}
        
        1 Reply Last reply Reply Quote 0
        • First post
          Last post