1
votes

i need help with Response Body Template. I am Using POST to "PutItem" in dynamoDB using APIGateway directly(No lambda).

The new item is added successfully but the response is Empty at 200

What I need is 1 - New row data 2 - Status 3 - Message

{
  "data": [],
  "status": "Success",
  "message": "Updated Succesfully"
}

without using lambda...Is this possible?

I tried many stuffs i.e.

#set($inputRoot = $input.path('$'))
{"templateId": "$elem.templateId.S",
"templateFileName": "$elem.templateFileName.S"}

but its showing null.

Here is my log when i run Test @API Gateway

Sat Feb 17 06:22:18 UTC 2018 : Endpoint request body after transformations:

{ 
    "TableName": "xyz-mobilehub-9260364_Template_Table",
    "Item": {
    "templateId": {
            "S": "APIGateway"
            },
        "templateFileName": {
            "S": "breaking-news-story-01-18-2016"
            },
        "templateName": {
            "S": "Just Saying Thank You"
        },
        "templateType": {
            "S": "I really enjoyed this story!!"
        }
    }
}

Sat Feb 17 06:22:18 UTC 2018 : Sending request to https://dynamodb.us-east-1.amazonaws.com/?Action=PutItem Sat Feb 17 06:22:18 UTC 2018 : Received response. Integration latency: 33 ms Sat Feb 17 06:22:18 UTC 2018 : Endpoint response body before transformations: {} Sat Feb 17 06:22:18 UTC 2018 : Endpoint response headers: {Server=Server, Connection=keep-alive, x-amzn-RequestId=RE631UNS84TACTMP4TE752UK0BVV4KQNSO5AEMVJF66Q9ASUAAJG, x-amz-crc32=2745614147, Content-Length=2, Date=Sat, 17 Feb 2018 06:22:17 GMT, Content-Type=application/x-amz-json-1.0} Sat Feb 17 06:22:18 UTC 2018 : Method response body after transformations:

{
"templateId": "",
"templateFileName": "",
}

Sat Feb 17 06:22:18 UTC 2018 : Method response headers: {X-Amzn-Trace-Id=Root=1-5a87ca19-62a291f9a923480f5c62884f, Content-Type=application/json} Sat Feb 17 06:22:18 UTC 2018 : Successfully completed execution Sat Feb 17 06:22:18 UTC 2018 : Method completed with status: 200

1

1 Answers

1
votes

Go to Integration Response in you API Gateway and give the response in the way you want. Please see below screenshots,

enter image description here

Select Integration Response,

enter image description here

under Generate Template provide your JSON data