Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

API gateway and DynamoDB integration - SerializationException

I have setup an API endpoint integration to DynamoDB. I want to query a table using query string parameter as query filter. Unfortunatley I ended up getting error:

Method response body after transformations: {"__type":"com.amazon.coral.service#SerializationException"}

with no clue what is the root cause.

To do the stated above I have taken the following steps:

1) Setup a get method in API gateway

enter image description here

2) In the Method Request I added a parameter to URL Query String Parameters enter image description here

3) In the integration request I added the same parameter from step 2 in URL Query String Parameters enter image description here

4)In DynamoDB table I decalred a new index for the column that I'd like to query

5)In body mapping template:

{
    "TableName": "tjusers",
    "IndexName" "badge-index",
    "KeyConditionExpression": "badge = :v1",
    "ExpressionAttributeValues": {
        ":v1": {
            "S": "$input.params('badge')"
        }
    }
}

enter image description here

THe exception:

xecution log for request f0081606-b521-11e8-adb2-cd8092221b33
Mon Sep 10 17:50:00 UTC 2018 : Starting execution for request: f0081606-b521-11e8-adb2-cd8092221b33
Mon Sep 10 17:50:00 UTC 2018 : HTTP Method: GET, Resource Path: /db/users
Mon Sep 10 17:50:00 UTC 2018 : Method request path: {}
Mon Sep 10 17:50:00 UTC 2018 : Method request query string: {badge=18323}
Mon Sep 10 17:50:00 UTC 2018 : Method request headers: {}
Mon Sep 10 17:50:00 UTC 2018 : Method request body before transformations: 
Mon Sep 10 17:50:00 UTC 2018 : Endpoint request URI: https://dynamodb.us-west-2.amazonaws.com/?Action=Query&badge=11111
Mon Sep 10 17:50:00 UTC 2018 : Endpoint request headers: {Authorization=****************************************************************************************************************************************************************************************************************************************************************************************feb2ac, X-Amz-Date=20180910T175000Z, x-amzn-apigateway-api-id=53zgcztitj, Accept=application/json, User-Agent=AmazonAPIGateway_53zgcztitj, X-Amz-Security-Token=AgoGb3JpZ2l....
Mon Sep 10 17:50:00 UTC 2018 : Endpoint request body after transformations: {
    "TableName": "tjusers",
    "IndexName" "badge-index",
    "KeyConditionExpression": "badge = :v1",
    "ExpressionAttributeValues": {
        ":v1": {
            "S": "11111"
        }
    }
}

Mon Sep 10 17:50:00 UTC 2018 : Sending request to https://dynamodb.us-west-2.amazonaws.com/?Action=Query&badge=18323
Mon Sep 10 17:50:00 UTC 2018 : Received response. Integration latency: 11 ms
Mon Sep 10 17:50:00 UTC 2018 : Endpoint response body before transformations: {"__type":"com.amazon.coral.service#SerializationException"}
Mon Sep 10 17:50:00 UTC 2018 : Endpoint response headers: {Server=Server, Date=Mon, 10 Sep 2018 17:49:59 GMT, Content-Type=application/x-amz-json-1.0, Content-Length=60, Connection=keep-alive, x-amzn-RequestId=ODMJ814D1GBN875T6MTR7BUHGVVV4KQNSO5AEMVJF66Q9ASUAAJG, x-amz-crc32=3948637019}
Mon Sep 10 17:50:00 UTC 2018 : Method response body after transformations: {"__type":"com.amazon.coral.service#SerializationException"}
Mon Sep 10 17:50:00 UTC 2018 : Method response headers: {X-Amzn-Trace-Id=Root=1-5b96aec8-addec09261723342f53a179f, Content-Type=application/json}
Mon Sep 10 17:50:00 UTC 2018 : Successfully completed execution
Mon Sep 10 17:50:00 UTC 2018 : Method completed with status: 200
like image 905
Nir-Z Avatar asked Sep 10 '18 17:09

Nir-Z


1 Answers

You are missing : after "IndexName", that cause SerializationException

enter image description here

like image 96
zoph Avatar answered Oct 21 '22 05:10

zoph