根据此处的 boto3 文档:https ://boto3.readthedocs.org/en/latest/reference/services/iot-data.html#client update_thing_shadow 方法将 thingName 和 JSON 有效负载作为参数。目前它是这样写的:
client = boto3.client('iot-data', region_name='us-east-1')
data = {"state" : { "desired" : { "switch" : "on" }}}
mypayload = json.dumps(data)
response = client.update_thing_shadow(
thingName = 'MyDevice',
payload = b'mypayload'
)
当我使用命令行时没有问题,但似乎无法从 Lamba 函数中得到它。我已经用许多版本的代码(json.JSONEncoder、bytearray() 等)调用了它,但没有任何运气。调用 UpdateThingShadow 操作时出现的错误范围从语法到 (ForbiddenException):错误请求:ClientError。有没有人从 AWS lambda 函数中成功调用此方法或类似方法?谢谢。