Error: dynamodb put item not working
What's Causing This Error
This error mainly occurs with the AWS JavaScript SDK when putItem()
function is used as a promise-based function.
For example, suppose you are executing the putItem()
in a Lambda function and do not wait until the execution is complete. The Lambda function will immediately return a response, but the putItem()
will not get executed.
Solution - Here's How To Resolve It
To resolve the error, use an async-await approach as shown below.
exports.handler = async (event) => { const obj = { pk: 1, name: "Lakindu" }; const response = { statusCode: 200, body: JSON.stringify(obj), }; var params = { 'TableName':'dynobase-article-demo', 'Item': { 'pk': { N: obj.pk }, 'name': { S: obj.name } }, 'ReturnConsumedCapacity': "TOTAL" }; // await for the put item so that it becomes synchronous. await dynamodb.putItem(params).promise(); return response; };
Other Common DynamoDB Errors (with Solutions)
- DynamoDB No Provisioned Throughput specified for the table
- DynamoDB error cannot find module build/Release/DTraceProviderBindings
- DynamoDB Internal Server Error
- failed to list tables not authorized dynamodb
- could not connect to the endpoint URL dynamodb
- dynamodb: one or more parameter values were invalid: type mismatch for index key
- dynamodb unable to locate property for key attribute
- DynamoDB local error spawn java ENOENT
- DynamoDB console unable to delete this item
- dynamodb throttle error code
- dynamodb value cannot be null. (parameter 'type')
- dynamodb localhost error
- DynamoDB failedbatch retry
- dynamodb property projection cannot be empty
- Error ValidationException: One or more parameter values were invalid: Type mismatch for key X expected: S actual: M
Better DynamoDB experience.
Try 7-day free trial. No strings attached.
Product Features
DynamoDB Tools
DynamoDB Info
© 2023 Dynobase