I'm stumped as to why I am getting the error. Seems like it is just ignoring the items that I pass in. I have tried the various combinations below and a lot of others. Tried get, delete , put methods etc, no luck.
Tried Changing 'Item' and 'Key' depending on the method of course. No idea what is wrong. Primary partition key is 'uid'
'table' is a variable with the table name
let params = {
TableName:{"S":table},
Item:{
uid: "2"
}
};
let params = {
TableName: table,
Item:{
uid: "2"
}
};
docClient.query(params, function(err, data) {
Here is the full error. I think 'M' refers to an an object so not sure why that is showing up as well.
"There were 2 validation errors: * MissingRequiredParameter: Missing required key 'TableName' in >params * UnexpectedParameter: Unexpected key 'M' found in params", "code": "MultipleValidationErrors", >"errors": {"message": "Missing required key 'TableName' in params","code":"MissingRequiredParameter",time": "2020-05-09T21:51:14.530Z"}, {message": "Unexpected key 'M' found in params", "code": "UnexpectedParameter", "time": "2020-05-09T21:51:14.530Z"} ],"time": "2020-05-09T21:51:14.530Z"\"}"
Here is the lambda function
var AWS = require("aws-sdk");
const docClient = new AWS.DynamoDB.DocumentClient('us-east-1');
exports.handler = async event => {
var tables = ['holdings','trades','userDetails'];
var table = 'userDetails'//tables[2]
var out = ''
var params = {
TableName: table,
Item: {
"uid": 2
}
};
docClient.put(params, function(err, data) {
if (err) {
console.log("Error", err)
} else {
console.log("PutItem succeeded")
}
});
let responseBody = {
message: 'Test',
par: params,
input: out
};
let response = {
statusCode: 200,
headers: {
"x-custom-header" : "Testing delete function"
},
body: JSON.stringify(responseBody)
};
return response
};