AWS IoT updateThing Не удалось выполнить ограничение, но данные в правильном формате - PullRequest
0 голосов
/ 27 февраля 2019

У меня есть следующий код, который вызывает updateThing из класса IoT в JavaScript SDK aws-sdk.Однако он выдает ошибку:

'{"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_.,@/:#-]*]",

Это внутри лямбда-функции:

  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
  });
...