1

我尝试使用aws nodejs sdk更新我的 IOT事物,但它给了我一个“验证错误”异常

代码:

var AWS = require("aws-sdk");
AWS.config.apiVersions = {
  iot: '2015-05-28',
};

var attribs = {};

attribs.type = "Type Value";
attribs.name = "Device Name";

var params = {
   thingName: thing_name,
   attributePayload: {
       attributes: attribs
   }
};

iot.updateThing(params, function(err, data) {
    if (err) {
        console.log(err, err.stack); // an error occurred
    } else {
        console.log(data); // successful response
    }
});

例外 :

message: '1 validation error detected: Value \'{name=Device Value, type=Type Value}\' at \'attributePayload.attributes\' failed to satisfy constraint: Map value must satisfy constraint: [Member must have length less than or equal to 1024, Member must have length greater than or equal to 0, Member must satisfy regular expression pattern: [a-zA-Z0-9_.,@/:#-]+]',
  code: 'InvalidRequestException',
  time: Mon Mar 14 2016 07:00:13 GMT+0000 (UTC),
  requestId: '53474c09-e9b2-11e5-a613-a924097ce6cf',
  statusCode: 400,
  retryable: false,
  retryDelay: 44.59372889250517

有人知道我的 updateThing 代码有什么问题吗?我需要更新一个物联网的东西

4

1 回答 1

1

IOT 事物的属性值不应包含空格

尝试以下属性

attribs.type = "Type_Value";
attribs.name = "Device_Name";

它工作得很好。也只能将三个属性附加到 IOT 设备。

于 2016-03-14T07:41:31.753 回答