I'm trying to add items to dynamodb by CLI using batch-write-item but receiving the error: "An error occurred (ValidationException) when calling the BatchWriteItem operation: The provided key element does not match the schema".
I'm using as reference the sample JSON from AWS docs.
Any clue what is missing?
{
"VertexMasterData":[
{
"PutRequest":{
"Item":{
"MasterDataID":{
"S":"0"
},
"ScenarioID":{
"S":"1"
},
"FlexibleFields":{
"M":{
"@fieldId4":{
"S":"4"
},
"@fieldId1":{
"S":"8517.12.31"
}
}
},
"Seller":{
"M":{
"MainDivision":{
"S":"SP"
}
}
},
"Destination":{
"M":{
"MainDivision":{
"S":"RJ"
}
}
}
}
}
},
{
"PutRequest":{
"Item":{
"MasterDataID":{
"S":"1"
},
"ScenarioID":{
"S":"1"
},
"FlexibleFields":{
"M":{
"@fieldId4":{
"S":"1"
},
"@fieldId1":{
"S":"3403.99.00"
}
}
},
"Seller":{
"M":{
"MainDivision":{
"S":"SP"
}
}
},
"Destination":{
"M":{
"MainDivision":{
"S":"AC"
}
}
}
}
}
},
{
"PutRequest":{
"Item":{
"MasterDataID":{
"S":"2"
},
"ScenarioID":{
"S":"1"
},
"FlexibleFields":{
"M":{
"@fieldId4":{
"S":"1"
},
"@fieldId1":{
"S":"3506.10.90"
}
}
},
"Seller":{
"M":{
"MainDivision":{
"S":"SP"
}
}
},
"Destination":{
"M":{
"MainDivision":{
"S":"AC"
}
}
}
}
}
}
]
}
Table details: VertexMasterData
CodePudding user response:
It looks like your records don't contain the primary key value or values. When you created the VertexMasterData table, you would have designated a Partition Key and possibly also a Sort Key. Any records added to that table must contain your primary key (all other fields are optional), which may be one or two fields.
To see the Partition Key and Sort Key for your table, go to AWS Console > DynamoDb > Tables.
CodePudding user response:
There is a space in the end of Partition key that I'm not considering in the JSON: Table: "MasterDataID " JSON: "MasterDataID"
