Error InvalidParameterType: Expected params.Item['pid'] to be a structure in DynamoDB

后端 未结 2 1260
猫巷女王i
猫巷女王i 2021-01-01 09:50

Note: all these are happening on the local instance of DynamoDB.

This is the code that I\'ve used to create a table from the DynamoDB Shell:

var para         


        
2条回答
  •  有刺的猬
    2021-01-01 10:10

    Note: This answer may no longer be valid as mentioned in multiple comments below.

    The function that must be used to add records into the database from nodejs is put and not putItem which is used in the DynamoDB shell. Changing the above function to the following fixed it.

    function(request, response) {
      params = {
        TableName: 'TABLE-NAME',
        Item: {
          pid: 'abc123'
        }
      };
      console.log(params);
      dynamodb.put(params, function(err, data) {
        if (err)
          console.log(JSON.stringify(err, null, 2));
        else
          console.log(JSON.stringify(data, null, 2));
      });
    }
    

提交回复
热议问题