我有以下代码,这些代码从aws-sdk JavaScript SDK中的IoT类调用updateThing。但是它会引发错误:
'{"errorMessage":"1 validation error detected: Value \'{asd={\\"asd\\":\\"asd\\"}, foo={\\"foo\\":\\"foo\\"}}\' at \'attributePayload.attributes\' failed to satisfy constraint: Map value must satisfy constraint: [Member must have length less than or equal to 800, Member must have length greater than or equal to 0, Member must satisfy regular expression pattern: [a-zA-Z0-9_.,@/:#-]*]",
这在Lambda函数中:
const aws = require('aws-sdk');
const IoT = new aws.Iot({
endpoint: 'iot.eu-west-1.amazonaws.com',
apiVersion: '2015-05-28'
})
const PARAMS = {
thingName: deviceId,
thingTypeName: 'StreetLight',
attributePayload: {
attributes: {
// should be the correct way of passing the object. expects a string value for each key
'asd': JSON.stringify({asd:'asd'}),
'foo': JSON.stringify({foo:'foo'})
}
}
,
};
IoT.updateThing(params, function(err, res) {
// code
});