排查Shelly Cloud API Python代码报错:'Wrong device id!'
问题:调用Shelly云API时持续返回"Wrong device id!"错误
我调用Shelly云API时一直收到如下错误:
{'isok': False, 'errors': {'wrong_device_id': 'Wrong device id!'}}
我已经尝试使用应用中指定的设备ID的十六进制(HEX)和十进制(decimal)格式,但错误仍未解决。此外,我用curl -X POST调用接口时,连授权环节都无法通过。
以下是我使用的Python代码:
# Import the requests module import requests # Set the URL for the request url = "https://********.shelly.cloud/device/relay/control" # Set the headers for the request headers = { "Authorization": "Bearer ******", "Content-Type": "application/json" } # Set the data for the request data = { "channel": "0", # The channel to turn off "turn": "off", # The desired state (off) "id": "*******" # The ID of the device (Tried both, HEX and DEC versions of device ID) } # Send the POST request and store the response response = requests.post(url, headers=headers, json=data) # Print the response JSON print(response.json())
我也按照Shelly云控制API文档中的说明尝试了curl调用,但问题依旧。
内容的提问来源于stack exchange,提问作者Slooki
相关产品推荐
相关产品推荐

