ValidationException error, AttributeValue cannot be empty string

335 Views Asked by At

I'm writing a program that downloads tweets from twitter and stores the information in DynamoDB. It uses the requests python library, API Gateway and AWS Lambda to communicate with the database.

For about three quarters of the tweets, I have no problem with the POST request to the database however, about a quarter of the tweets get an error. Can someone explain the error?

I've included the section of code that deals with the request. The error says an Attribute cannot contain an empty string so in an attempt to deal with that, I've set default values for each field.

        h = {
            'content-type': 'application/json'
        }
        payload = {
            "created_at": d.get('created_at',"a"),# String
            "text": d.get("text","a"),# String
            "id": d.get('id_str',"0"), # String
            "payload": d, #json object
            "coordinates":d.get("geo","a"), # true or json object
            "quality": getQuality(d) # a number
        }
        r = requests.post(url, data=json.dumps(payload), headers=h)

enter image description here

0

There are 0 best solutions below