/    Sign up×
Community /Pin to ProfileBookmark

Amazon Web Services, dynamoDB, updateItem not working

Novice AWS clientside user here, & novice JavaScript autodidact who hopes someone out there uses AWS’ dynamoDB and is willing to help.

I intercept a form on a submit event and capture the form data. I want to use it to update a dynamoaDB table on AWS’s servers. As far as I can tell, I’ve defined the parameters variable that is used in the updateitem call precisely as instructed in the user documentation and by one of their support techs.

I get back an error message saying there are 13 validation errors in the params variable. The enumerated errors make no sense to me. There’s nothing in them that seems to relate to what I defined. There is an error that says an object in params is expected to have been a “structure,” whatever that means.

The code defining params and making the update call is produced below. After that is the full text of the console-logged error message from AWS. Before making the call, I logged params to the console, so, you can see what the object is that AWS is being sent.

Any help will be appreciated to such an extent that I will polish your shoes for six months.

The JavaScript min case:

$(document).ready( function() {
init();

});
function init() {
document.addEventListener(“submit”, updateTable);
} // end def fn init

function updateTable(){
var dynamoDB = new AWS.DynamoDB();
params0 = {
TableName: ‘FHCRoomCounts’,
Key: {
timeSlot: ‘0830’,
room: ‘chapel’,
},
UpdateExpression: ‘ADD registrants :n’,
ExpressionAttributeValues: {
‘:n’ : 1,
},
ReturnValues: ‘ALL_NEW’
};

console.log(‘log params0 : ‘);
for(let [key, value] of Object.entries(params0)) {
console.log(key, value);
} // end for-let
console.log(‘calling dynamoDB.updateItem’);

The error message back from AWS:

( 4.3) Logging paramKey after removeUnsures
Object { timeslot: “0830”, room: “chapel” }
Object { timeslot: “0900”, room: “A” }
Object { timeslot: “1245”, room: “B” }
Object { timeslot: “1415”, room: “A” }
Object { timeslot: “1545”, room: “I” }
{
“message”: “There were 13 validation errors:n* InvalidParameterType: Expected params.Key[‘timeSlot’] to be a structuren* UnexpectedParameter: Unexpected key ‘0’ found in params.Key[‘timeSlot’]n* UnexpectedParameter: Unexpected key ‘1’ found in params.Key[‘timeSlot’]n* UnexpectedParameter: Unexpected key ‘2’ found in params.Key[‘timeSlot’]n* UnexpectedParameter: Unexpected key ‘3’ found in params.Key[‘timeSlot’]n* InvalidParameterType: Expected params.Key[‘room’] to be a structuren* UnexpectedParameter: Unexpected key ‘0’ found in params.Key[‘room’]n* UnexpectedParameter: Unexpected key ‘1’ found in params.Key[‘room’]n* UnexpectedParameter: Unexpected key ‘2’ found in params.Key[‘room’]n* UnexpectedParameter: Unexpected key ‘3’ found in params.Key[‘room’]n* UnexpectedParameter: Unexpected key ‘4’ found in params.Key[‘room’]n* UnexpectedParameter: Unexpected key ‘5’ found in params.Key[‘room’]n* InvalidParameterType: Expected params.ExpressionAttributeValues[‘:n’] to be a structure”,
“code”: “MultipleValidationErrors”,
“errors”: [
{
“message”: “Expected params.Key[‘timeSlot’] to be a structure”,
“code”: “InvalidParameterType”,
“time”: “2019-06-15T02:22:09.571Z”
},
{
“message”: “Unexpected key ‘0’ found in params.Key[‘timeSlot’]”,
“code”: “UnexpectedParameter”,
“time”: “2019-06-15T02:22:09.571Z”
},
{
“message”: “Unexpected key ‘1’ found in params.Key[‘timeSlot’]”,
“code”: “UnexpectedParameter”,
“time”: “2019-06-15T02:22:09.571Z”
},
{
“message”: “Unexpected key ‘2’ found in params.Key[‘timeSlot’]”,
“code”: “UnexpectedParameter”,
“time”: “2019-06-15T02:22:09.571Z”
},
{
“message”: “Unexpected key ‘3’ found in params.Key[‘timeSlot’]”,
“code”: “UnexpectedParameter”,
“time”: “2019-06-15T02:22:09.571Z”
},
{
“message”: “Expected params.Key[‘room’] to be a structure”,
“code”: “InvalidParameterType”,
“time”: “2019-06-15T02:22:09.571Z”
},
{
“message”: “Unexpected key ‘0’ found in params.Key[‘room’]”,
“code”: “UnexpectedParameter”,
“time”: “2019-06-15T02:22:09.571Z”
},
{
“message”: “Unexpected key ‘1’ found in params.Key[‘room’]”,
“code”: “UnexpectedParameter”,
“time”: “2019-06-15T02:22:09.571Z”
},
{
“message”: “Unexpected key ‘2’ found in params.Key[‘room’]”,
“code”: “UnexpectedParameter”,
“time”: “2019-06-15T02:22:09.572Z”
},
{
“message”: “Unexpected key ‘3’ found in params.Key[‘room’]”,
“code”: “UnexpectedParameter”,
“time”: “2019-06-15T02:22:09.572Z”
},
{
“message”: “Unexpected key ‘4’ found in params.Key[‘room’]”,
“code”: “UnexpectedParameter”,
“time”: “2019-06-15T02:22:09.572Z”
},
{
“message”: “Unexpected key ‘5’ found in params.Key[‘room’]”,
“code”: “UnexpectedParameter”,
“time”: “2019-06-15T02:22:09.572Z”
},
{
“message”: “Expected params.ExpressionAttributeValues[‘:n’] to be a structure”,
“code”: “InvalidParameterType”,
“time”: “2019-06-15T02:22:09.572Z”
}
],
“time”: “2019-06-15T02:22:09.572Z”,
“stack”: “validate@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:61:19246n[311]</a.EventListeners.Core</<@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:60:25947ncallListeners@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:62:26769ns@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:62:26635n[311]</a.EventListeners.Core</</<@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:60:25280nt@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:59:25669ngetCredentials/</<@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:59:25990nget@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:59:30534ngetCredentials/<@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:59:25896ngetCredentials@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:59:25997n[311]</a.EventListeners.Core</<@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:60:25149ncallListeners@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:62:26740nemit@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:62:26480nemitEvent@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:62:12277ne@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:62:7919n[363]</i.prototype.runTo@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:64:9533nrunTo@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:62:9575nsend@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:62:9468nmakeRequest@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:62:30482ndefineMethods/</e.prototype[t]@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:63:5136nupdateTable@https://steve-alexander-pfmi.squarespace.com/test-register-2019:332:12nprocessData@https://steve-alexander-pfmi.squarespace.com/
}

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @alxfyv spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.15,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...