3
votes

I am trying to update DynamoDB and I send JSON data from Rasperry PI or MQTT Client, but when I look to CloudWatch I see below error message.

EVENT:DynamoActionFailure TOPICNAME:iotbutton/test CLIENTID:MQTT_FX_Client MESSAGE:Dynamo Insert record failed. The error received was Attribute name must not be null or empty. Message arrived on: iotbutton/test, Action: dynamo, Table: myTable_IoT, HashKeyField: SerialNumber, HashKeyValue: ABCDEFG12345, RangeKeyField: Some(ClickType), RangeKeyValue: SINGLE

I am using the AWS IoT Tutorial (http://docs.aws.amazon.com/iot/latest/developerguide/iot-dg.pdf), The Seccion: Creating a DynamoDB Rule.

The data I send to the IoT platform is:

{
 "serialNumber" : "ABCDEFG12345",
 "clickType" : "SINGLE",
 "batteryVoltage" : "5v USB"
}

topic: iotbutton/ABCDEFG12345

Does anyone come across this error and aware of any solution?

Thanks, regards.

1
It looks to me that you didn't capitolize the s of SerialNumber, vs serialNumer in your data, and the same with ClickType. Expect capitalization to matter in AWS across the board.Daniel Farrell

1 Answers

3
votes

This is the message the CloudWatch logs showed when a tried doing this:

{ 
  "timestamp": "2019-01-28 21:26:16.363", 
  "logLevel": "ERROR", 
  "traceId": "9e3ff9b0-fcdf-d8ae-e8a8-4b7a24902405", 
  "accountId": "xxx", 
  "status": "Failure", 
  "eventType": "RuleExecution", 
  "clientId": "basicPubSub", 
  "topicName": "xxx/r117", 
  "ruleName": "devCompDynamoDB", 
  "ruleAction": "DynamoAction", 
  "resources": 
  { 
    "ItemRangeKeyValue": "SINGLE", 
    "IsPayloadJSON": "true", 
    "ItemHashKeyField": "SerialNumber", 
    "Operation": "Insert", 
    "ItemRangeKeyField": "ClickType", 
    "Table": "TestIoTDataTable", 
    "ItemHashKeyValue": "ABCDEFG12345" 
  }, 
  "principalId": "xx", 
  "details": "Attribute name must not be null or empty" 
}

To Fix it I edited the DynamoDB Rule in the IoT Web Console and I added a payload column in the "Write message data to this column" field.

Example Image