Reputation: 446
I want to call BatchGetItem to fetch multiple documents from simple table in DynamoDB using API Gateway json mapping template inside integration request. Below template works for me when using Query action to get single item:
{
"TableName": "Test",
"KeyConditionExpression": "ItemId = :i",
"ExpressionAttributeValues": {
":i": {
"N": "7"
}
}
When I change action to BatchGetItem and use following template I always get "__type": "com.amazon.coral.service#SerializationException" with status 400.
Endpoint request body after transformations in log looks correct and is exactly the template below. I also tested same request with nodejs sdk and it works perfect.
{
RequestItems: {
"Test": {
Keys: [
{ "ItemId": 7 }
],
ProjectionExpression: "ItemId,Status,EventTime"
}
}
}
also tried this:
{
RequestItems: {
"Test": {
Keys: [
{ "ItemId": {"N":"7" }}
],
ProjectionExpression: "ItemId,Status,EventTime"
}
}
}
Upvotes: 2
Views: 646
Reputation: 446
I managed to solve this by wrapping all properties and values as strings and setting key value type
{
"RequestItems": {
"Test": {
"Keys": [
{ "ItemId": {"N":"7" }}
],
"ProjectionExpression": "ItemId,Status,EventTime"
}
}
}
Upvotes: 2