1
votes

I am trying to update a json response to an item in AWS DynamoDB and getting below error. Could someone please help on this

import boto3
import json

dynamoDB = boto3.client('dynamodb')

def lambda_handler(event, context):
    testinfo = {"Smile":{"Confidence": '99.8970947265625',"Value": 
"True"}}
    dynamoDB.put_item(TableName='DetectedInfo',Item={'DateTime': 
'12282018','Info': json.dumps(testinfo)})

Error:

ParamValidationError: Parameter validation failed: Invalid type for parameter Item.Info, value: [{"Smile": {"Confidence": "99.8970947265625", "Value": "True"}}], type: , valid types: Invalid type for parameter Item.DateTime, value: 12132018, type: , valid types:

1
Yyyymmdd is preferable to mmddyyyy or ddmmyyyy because it makes chronological and lexiconographic order the same. It's also unambiguous unlike many dates expressed the other ways (12012018 - December or January?) - Daniel Farrell

1 Answers

2
votes

It has to be of form:

dynamoDB.put_item(TableName='DetectedInfo',
Item={
'DateTime': {
'N':'12282018'},
'Info': {
'S':json.dumps(testinfo)}
})

Here N,S is the type of variable.You need to check allowed data types in aws documentation and apply accordingly.