呼叫PutItem操作时发生错误(验证Exception):一个或多个参数值无效:缺少键创建的键
帮助,我完全感到困惑,为什么我会遇到此错误,这表明当putitem()调用putitem()时缺少Createat字段。我将电子邮件摄取到S3存储桶中,然后从S3中取出并加载到Dynamo日志表中。完成后,将记录上传到Salesforce作为潜在客户记录。上传到Salesforce的工作正常,但是一路上我在写入Dynamo日志表时会遇到此错误。
我使用AWS控制台创建我的DynamoDB日志表来定义 分区密钥(cogid)和排序键(创建)
然后,我使用以下python函数代码添加我的数据 - self.data-使用PUT项目函数到DynamoDblog表。数据 包括创建的键及其值self。现在包含 dateTime.now()的字符串值
#Records Processed Logs
def processed_records_logging(self,action,object_type,object_id,existing_payload=None):
print('processed_records_logging')
print(self.global_payload)
try:
self.random_id = urandom(20).hex()
self.now = str(datetime.now())
self.detailResult = self.global_payload['Records'][0]['dynamodb']['NewImage']['Information']
self.ext_id = '-'
if 'ExternalId' in self.global_payload['Records'][0]['dynamodb']['NewImage']:
self.ext_id = self.global_payload['Records'][0]['dynamodb']['NewImage']['ExternalId']
self.data = {'CogId' : self.random_id, 'Month': self.today_month,'Year': self.today_year,'Day': self.today_date, 'LinkingCogId' : self.global_payload['Records'][0]['dynamodb']['NewImage']['CogId'], 'Action': action, 'Object': object_type, 'Id':object_id, 'NewInformation' : self.detailResult, 'Result': 'Pass', 'CreatedAt': self.now, 'ExternalId' : self.ext_id}
print('data in processed')
print('<< SELF DATA>> ',self.data)
# self.data['DuplicateUpdateInfo'] = {'result': None}
# self.data['DuplicateExistingInfo'] = {'result': None}
# self.data['Message'] = {'result': None}
if existing_payload != None:
self.data['OldInformation'] = existing_payload
# else:
# self.data['OldInformation'] = {'result': None}
print(self.data)
self.response = self.logItem.put_item(Item = self.data)
print(self.response)
if self.response['ResponseMetadata']['HTTPStatusCode'] == 200:
return {}
else:
return {}
except Exception as e:
print(e)
print('in processed_records_logging')
return {}
第三个图显示,当数据添加到 来自S3的Dynamo表,请注意,创建日期已添加到 将字典加载到DynamoDB日志表中:
<< SELF DATA>> {'CogId': 'e52119a733a0d60969564920187ef155d62de303', 'Month': '05', 'Year': '2022', 'Day': '07', 'LinkingCogId': '96cffaab877997d4a8be1b50df2c65fc4fac51ae', 'Action': 'Create', 'Object': 'Task', 'Id': '00T75000003serBEAQ', 'NewInformation': {'Company': 'Consolidated Supplies LLC', 'BDM_Sender_Last_Name__c': 'Patrick', 'Email': '[email protected]', 'BDM_Sender_Email__c': '[email protected]', 'FirstName': 'Loretta', 'PostalCode': '32399', ' Power_Usage__c': 'Under $5,000 / Month', 'Campaign_ID__c': '7014N000001TMORQA4', 'LastName': 'Sloan', 'BDM_Sender_First_Name__c': 'Tara', 'MQP_Type__c': 'SMB Shopping Site', 'Designated_Owner__c': '005410000032u2MAAQ', 'OwnerId': '005410000032u2MAAQ'}, 'Result': 'Pass', 'CreatedAt': '2022-05-07 02:10:39.426901', 'ExternalId': '-'}
最后,以下代码段显示了发生的错误:
{'CogId': 'e52119a733a0d60969564920187ef155d62de303', 'Month': '05', 'Year': '2022', 'Day': '07', 'LinkingCogId': '96cffaab877997d4a8be1b50df2c65fc4fac51ae', 'Action': 'Create', 'Object': 'Task', 'Id': '00T75000003serBEAQ', 'NewInformation': {'Company': 'Consolidated Supplies LLC', 'BDM_Sender_Last_Name__c': 'Patrick', 'Email': '[email protected]', 'BDM_Sender_Email__c': '[email protected]', 'FirstName': 'Loretta', 'PostalCode': '32399', ' Power_Usage__c': 'Under $5,000 / Month', 'Campaign_ID__c': '7014N000001TMORQA4', 'LastName': 'Sloan', 'BDM_Sender_First_Name__c': 'Tara', 'MQP_Type__c': 'SMB Shopping Site', 'Designated_Owner__c': '005410000032u2MAAQ', 'OwnerId': '005410000032u2MAAQ'}, 'Result': 'Pass', 'CreatedAt': '2022-05-07 02:10:39.426901', 'ExternalId': '-'}
2022-05-06T21:10:39.630-05:00
调用PutItem操作时发生错误(验证Exception):一个或多个参数值无效:在项目中丢失了键创建的键
Help, I am totally perplexed as to why I am getting this error indicating that CreateAt field is missing when a PutItem() is called. I an ingesting emails into an S3 bucket which are then taken from the S3 and loaded into the Dynamo log table. Once that is completed, the record is then uploaded to Salesforce as a lead record. The upload to Salesforce works correctly but along the way I get this error when writing to the Dynamo log table.
I used AWS Console to create my DynamoDB log table to define both the
partition key (CogId) and Sort key (CreatedAt)
I then use the following python function code to add my data -
self.data - to DynamoDBlog table using the Put Item function. The data
includes the CreatedAt key and its value self.now which contains the
string value of datetime.now()
#Records Processed Logs
def processed_records_logging(self,action,object_type,object_id,existing_payload=None):
print('processed_records_logging')
print(self.global_payload)
try:
self.random_id = urandom(20).hex()
self.now = str(datetime.now())
self.detailResult = self.global_payload['Records'][0]['dynamodb']['NewImage']['Information']
self.ext_id = '-'
if 'ExternalId' in self.global_payload['Records'][0]['dynamodb']['NewImage']:
self.ext_id = self.global_payload['Records'][0]['dynamodb']['NewImage']['ExternalId']
self.data = {'CogId' : self.random_id, 'Month': self.today_month,'Year': self.today_year,'Day': self.today_date, 'LinkingCogId' : self.global_payload['Records'][0]['dynamodb']['NewImage']['CogId'], 'Action': action, 'Object': object_type, 'Id':object_id, 'NewInformation' : self.detailResult, 'Result': 'Pass', 'CreatedAt': self.now, 'ExternalId' : self.ext_id}
print('data in processed')
print('<< SELF DATA>> ',self.data)
# self.data['DuplicateUpdateInfo'] = {'result': None}
# self.data['DuplicateExistingInfo'] = {'result': None}
# self.data['Message'] = {'result': None}
if existing_payload != None:
self.data['OldInformation'] = existing_payload
# else:
# self.data['OldInformation'] = {'result': None}
print(self.data)
self.response = self.logItem.put_item(Item = self.data)
print(self.response)
if self.response['ResponseMetadata']['HTTPStatusCode'] == 200:
return {}
else:
return {}
except Exception as e:
print(e)
print('in processed_records_logging')
return {}
The third diagram shows that when the data is being added to the
Dynamo Table from S3 and note that the CreatedAt date is added to the
dictionary to be loaded into the DynamoDB Log Table:
<< SELF DATA>> {'CogId': 'e52119a733a0d60969564920187ef155d62de303', 'Month': '05', 'Year': '2022', 'Day': '07', 'LinkingCogId': '96cffaab877997d4a8be1b50df2c65fc4fac51ae', 'Action': 'Create', 'Object': 'Task', 'Id': '00T75000003serBEAQ', 'NewInformation': {'Company': 'Consolidated Supplies LLC', 'BDM_Sender_Last_Name__c': 'Patrick', 'Email': '[email protected]', 'BDM_Sender_Email__c': '[email protected]', 'FirstName': 'Loretta', 'PostalCode': '32399', ' Power_Usage__c': 'Under $5,000 / Month', 'Campaign_ID__c': '7014N000001TMORQA4', 'LastName': 'Sloan', 'BDM_Sender_First_Name__c': 'Tara', 'MQP_Type__c': 'SMB Shopping Site', 'Designated_Owner__c': '005410000032u2MAAQ', 'OwnerId': '005410000032u2MAAQ'}, 'Result': 'Pass', 'CreatedAt': '2022-05-07 02:10:39.426901', 'ExternalId': '-'}
Finally, the following code snippet shows the error that occurs:
{'CogId': 'e52119a733a0d60969564920187ef155d62de303', 'Month': '05', 'Year': '2022', 'Day': '07', 'LinkingCogId': '96cffaab877997d4a8be1b50df2c65fc4fac51ae', 'Action': 'Create', 'Object': 'Task', 'Id': '00T75000003serBEAQ', 'NewInformation': {'Company': 'Consolidated Supplies LLC', 'BDM_Sender_Last_Name__c': 'Patrick', 'Email': '[email protected]', 'BDM_Sender_Email__c': '[email protected]', 'FirstName': 'Loretta', 'PostalCode': '32399', ' Power_Usage__c': 'Under $5,000 / Month', 'Campaign_ID__c': '7014N000001TMORQA4', 'LastName': 'Sloan', 'BDM_Sender_First_Name__c': 'Tara', 'MQP_Type__c': 'SMB Shopping Site', 'Designated_Owner__c': '005410000032u2MAAQ', 'OwnerId': '005410000032u2MAAQ'}, 'Result': 'Pass', 'CreatedAt': '2022-05-07 02:10:39.426901', 'ExternalId': '-'}
2022-05-06T21:10:39.630-05:00
An error occurred (ValidationException) when calling the PutItem operation: One or more parameter values were invalid: Missing the key CreatedAt in the item
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)