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
Go to Integration Response in you API Gateway and give the response in the way you want. Please see below screenshots,
Select Integration Response,
under Generate Template provide your JSON data
Related
I am trying to create a serverless contact form in S3 that calls AWS API Gateway that then interacts with SES to send an email to a "contact us" email recipient. I am following the tutorial at https://levelup.gitconnected.com/creating-a-serverless-contact-form-on-aws-ff339ad1fa60 and am stuck at the part where I've created the API and am trying to test it with a JSON payload. The problem is the API test behaves as expected and returns a successful http 200 BUT it seems SES is returning an error that looks like ->
{"Error":{"Code":"SignatureDoesNotMatch","Message":"The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.","Type":"Sender"},"RequestId":"1559f1b5-7000-4fe5-9d70-38b729adba46"}
Here is the entire execution stack from the API test in the AWS API configuration area ->
Execution log for request a18a0aa1-fa42-4bc8-a3c0-c6754716398f
Fri Dec 02 20:19:12 UTC 2022 : Starting execution for request: a18a0aa1-fa42-4bc8-a3c0-c6754716398f
Fri Dec 02 20:19:12 UTC 2022 : HTTP Method: POST, Resource Path: /
Fri Dec 02 20:19:12 UTC 2022 : Method request path: {}
Fri Dec 02 20:19:12 UTC 2022 : Method request query string: {}
Fri Dec 02 20:19:12 UTC 2022 : Method request headers: {}
Fri Dec 02 20:19:12 UTC 2022 : Method request body before transformations: {
"name": "Test Name",
"email": "test#test.com",
"phone": "123-456-7890",
"message": "This is a test message!"
}
Fri Dec 02 20:19:12 UTC 2022 : Endpoint request URI: https://email.us-east-1.amazonaws.com/SendEmail
Fri Dec 02 20:19:12 UTC 2022 : Endpoint request headers: {Authorization=************************************************************************************************************************************************************************************************************************************************************************098c83, X-Amz-Date=20221202T201912Z, x-amzn-apigateway-api-id=1j6iefoiqj, Accept=application/json, User-Agent=AmazonAPIGateway_1j6iefoiqj, X-Amz-Security-Token=IQoJb3JpZ2luX2VjEJX//////////wEaCXVzLWVhc3QtMSJHMEUCIAVdXRcxBZlgf9mN9jqp6OxEtITF/KMl+MzbXyb89NZrAiEAzSxr6P0cIMDwGDkkXOYr1C2KINbRKN2X0zozBMh7fjIq7gIIrf//////////ARADGgwzMzc2MzIxMzUyNDQiDHpwxD6RfZw5uGjCHirCAse0l62z8auypaCu5K+bUgeCqsXqtE7bjBhct1ZG0WK5q5gw3DRKGLPmqPc9nFZ1pbeRUCw5LvuuI+6jQKs2CCJisZlgrGjSD/m1akgPkVsR1FtCNj6z7GEURaTg6r3aqz2KXyrHVft4cex+BoSOeMUMBBXWOKJirppkK8KGz4yNNPYFJ1BPLWQJcWOb6rPi/87pPoey0E3PiwLf1SXTVzkc/S/I/tpLzV7fARx4vheXC7c+SmAHyg/Zm318As5OBCqGBPXKpK0UT/7z4r9/vqDRzCsXXe0FCGJjOyMuM5y9k5bnsT5sRjpenX1DOkUopLoEsc2xTjunfEXKGmfn+M96I+Z3JbrnGMz [TRUNCATED]
Fri Dec 02 20:19:12 UTC 2022 : Endpoint request body after transformations: Action=SendEmail&Message.Body.Text.Data=%0AName%3A+%22Test+Name%22%0AEmail%3A+%22test%40test.com%22%0APhone%3A+%22123-456-7890%22%0AMessage%3A+%22This+is+a+test+message%21%22&Message.Subject.Data=Contact+form+submission&Destination.ToAddresses.member.1=DudeDudely%40hotmail.com&Source=no_reply_contact_form_submission%40ThatBigTLD.com
Fri Dec 02 20:19:12 UTC 2022 : Sending request to https://email.us-east-1.amazonaws.com/SendEmailToWhomeverILike
Fri Dec 02 20:19:12 UTC 2022 : Received response. Status: 403, Integration latency: 21 ms
Fri Dec 02 20:19:12 UTC 2022 : Endpoint response headers: {Date=Fri, 02 Dec 2022 20:19:12 GMT, Content-Type=application/json, Content-Length=300, Connection=keep-alive, x-amzn-RequestId=1559f1b5-7000-4fe5-9d70-38b729adba46}
Fri Dec 02 20:19:12 UTC 2022 : Endpoint response body before transformations: {"Error":{"Code":"SignatureDoesNotMatch","Message":"The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.","Type":"Sender"},"RequestId":"1559f1b5-7000-4fe5-9d70-38b729adba46"}
Fri Dec 02 20:19:12 UTC 2022 : Method response body after transformations: {"Error":{"Code":"SignatureDoesNotMatch","Message":"The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.","Type":"Sender"},"RequestId":"1559f1b5-7000-4fe5-9d70-38b729adba46"}
Fri Dec 02 20:19:12 UTC 2022 : Method response headers: {X-Amzn-Trace-Id=Root=1-638a5dc0-85f935e6291eab49e7dbe023, Content-Type=application/json}
Fri Dec 02 20:19:12 UTC 2022 : Successfully completed execution
Fri Dec 02 20:19:12 UTC 2022 : Method completed with status: 200
I have also tested this in Postman and I get the same results. The JSON payload I used in the test looks like ->
{
"name": "Test Name",
"email": "test#test.com",
"phone": "123-456-7890",
"message": "This is a test message!"
}
I have an IAM role associated with this api that looks like ```
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Custom",
"Effect": "Allow",
"Action": [
"ses:SendEmail"
],
"Resource": "*"
}
]
}
This IAM role's ARN is referenced in the Integration Request section as
Execution role
arn:aws:iam::<ABigNumberImNotGoingToShowYou>:role/ApiGatewaySes
My main question is ....... do I also need to send some other type of authentication token? If so where would I configure that information?
I try to use DYnamoDB directly from the API Gateway.
Before I successfully used GET method with Lambda. My lambda was used only for selection from the DynamoDB, so I decided to implement this simple query directly, so my steps:
I created {id} source and the GET method:
(need to note - the POST method works well via a lambda)
Updated the integration request:
updated Trust relationships for the role:
also Role has permissions for the GetItem:
after I updated the Mapped Templates:
{
"TableName": "Link",
"Key":
"id": {
"S": '$input.params("id")'
}
}
}
So, after method testing, I receive the following errors:
request: "S": '$input.params("id")'
error: {"__type":"com.amazon.coral.service#SerializationException"}
Additional info from the response:
Endpoint request body after transformations: {
"TableName": "Link",
"Key":
"id": {
"S": "3MEJh"
}
}
}
database cortage:
Full logs:
Execution log for request -30fa-4e7a-8524-ba0dde7375dd
Sun Oct 02 18:57:39 UTC 2022 : Starting execution for request: 1cc6e9fe-30fba0dde7375dd
Sun Oct 02 18:57:39 UTC 2022 : HTTP Method: GET, Resource Path: /3MEJh
Sun Oct 02 18:57:39 UTC 2022 : Method request path: {id=3MEJh}
Sun Oct 02 18:57:39 UTC 2022 : Method request query string: {}
Sun Oct 02 18:57:39 UTC 2022 : Method request headers: {}
Sun Oct 02 18:57:39 UTC 2022 : Method request body before transformations:
Sun Oct 02 18:57:39 UTC 2022 : Endpoint request URI: https://dynamodb.us-east-1.amazonaws.com/?Action=GetItem
Sun Oct 02 18:57:39 UTC 2022 : Endpoint request headers: {Authorization=, X-Amz-Date=20221002T185739Z, x-amzn-apigateway-api-id=, Accept=application/json, User-Agent=AmazonAPIGateway_, X-Amz-Security-Token= [TRUNCATED]
Sun Oct 02 18:57:39 UTC 2022 : Endpoint request body after transformations: {
"TableName": "Link",
"Key":
"id": {
"S": "3MEJh"
}
}
}
Sun Oct 02 18:57:39 UTC 2022 : Sending request to https://dynamodb.us-east-1.amazonaws.com/?Action=GetItem
Sun Oct 02 18:57:39 UTC 2022 : Received response. Status: 400, Integration latency: 6 ms
Sun Oct 02 18:57:39 UTC 2022 : Endpoint response headers: {Server=Server, Date=Sun, 02 Oct 2022 18:57:39 GMT, Content-Type=application/x-amz-json-1.0, Content-Length=60, Connection=keep-alive, x-amzn-RequestId=I669H6IF6GJD7NVV4KQNSO5AEMVJF66Q9ASUAAJG, x-amz-crc32=34863019}
Sun Oct 02 18:57:39 UTC 2022 : Endpoint response body before transformations: {"__type":"com.amazon.coral.service#SerializationException"}
Sun Oct 02 18:57:39 UTC 2022 : Method response body after transformations: {"__type":"com.amazon.coral.service#SerializationException"}
Sun Oct 02 18:57:39 UTC 2022 : Method response headers: {X-Amzn-Trace-Id=Root=339df23-575ea99d20ce6fb213b97a7b, Content-Type=application/json}
Sun Oct 02 18:57:39 UTC 2022 : Successfully completed execution
Sun Oct 02 18:57:39 UTC 2022 : Method completed with status: 200
I need to say - I had the same result when I broke my JSON request...so it seems the problem is another point.
So, what did I do wrong?
I'm trying to test out API gateway and Lambda functions however I can't seem to get my API gateway to connect to the Lambda function.
I started by creating a lambda function with node.js. I set an environment variable NODE_ENV: production.
Next I use API Gateway to create a REST API and configure a resource. I configure as a proxy resource, set my resource name to employee-api, and finally set the resource path to {proxy+}.
After I create my resource I connect it to my lambda function and deploy. Lastly I set Deployment Stage to [New Stage] and Stage Name to prod.
Now I zip a file containing my server code to import to my lambda.
package.json
{
"name": "employee-management",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"deploy": "npm run clean && npm run build && aws lambda update-function-code --function-name employees --zip-file fileb://build.zip --publish",
"clean": "rm build.zip",
"build": "zip -r build.zip node_modules index.js app.js routes.js",
"start": "TABLE='employees' node app-local",
"dynamodb-local-run": "docker-compose up",
"create-database": "aws dynamodb create-table --cli-input-json file://employee-table-model.json --endpoint-url http://localhost:8080"
},
"author": "",
"license": "ISC",
"dependencies": {
"aws-sdk": "^2.828.0",
"aws-serverless-express": "^3.4.0",
"cors": "^2.8.5",
"express": "^4.17.1",
"uuid": "^3.4.0"
}
}
index.js
const awsServerlessExpress = require('aws-serverless-express')
const app = require('./app')
const server = awsServerlessExpress.createServer(app)
exports.handler = (event, context) => { awsServerlessExpress.proxy(server, event, context) }
app.js
const express = require('express')
const app = express();
const bodyParser = require('body-parser');
const cors = require('cors');
const awsServerlessExpressMiddleware = require('aws-serverless-express/middleware')
const routes = require('./routes');
app.use(cors());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(awsServerlessExpressMiddleware.eventContext());
app.use('/', routes);
module.exports = app;
routes.js
const AWS = require('aws-sdk');
const express = require('express');
const uuid = require('uuid');
const IS_OFFLINE = process.env.NODE_ENV !== 'production';
const router = express.Router();
router.get('/employees', (req, res) => {
res.json(result)
});
module.exports = router;
I am able to successfully upload the zip folder. However, when I try to my API gateway endpoint /employees I am getting a 500 Internal Server Error.
I would really appreciate some guidance here.
Edit: As requested I am attaching the logs.
Response Body
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Internal Server Error</pre>
</body>
</html>
Response Headers
{"access-control-allow-origin":"*","date":"Sun, 17 Jan 2021 23:19:50 GMT","content-length":"148","content-security-policy":"default-src 'none'","x-content-type-options":"nosniff","x-powered-by":"Express","content-type":"text/html; charset=utf-8","connection":"close","X-Amzn-Trace-Id":"Root=1-6004c616-049f5587907c5f7d284b2b32;Sampled=0"}
Response Logs
Execution log for request 540fb10a-6f09-454e-9eaa-15b4f8426d35
Sun Jan 17 23:19:50 UTC 2021 : Starting execution for request: 540fb10a-6f09-454e-9eaa-15b4f8426d35
Sun Jan 17 23:19:50 UTC 2021 : HTTP Method: GET, Resource Path: /employees
Sun Jan 17 23:19:50 UTC 2021 : Method request path: {proxy=employees}
Sun Jan 17 23:19:50 UTC 2021 : Method request query string: {}
Sun Jan 17 23:19:50 UTC 2021 : Method request headers: {}
Sun Jan 17 23:19:50 UTC 2021 : Method request body before transformations:
Sun Jan 17 23:19:50 UTC 2021 : Endpoint request URI: https://lambda.us-east-1.amazonaws.com/2015-03-31/functions/arn:aws:lambda:us-east-1:451162917588:function:employee/invocations
Sun Jan 17 23:19:50 UTC 2021 : Endpoint request headers: {x-amzn-lambda-integration-tag=540fb10a-6f09-454e-9eaa-15b4f8426d35, Authorization=************************************************************************************************************************************************************************************************************************************************************************************************************************aac4ac, X-Amz-Date=20210117T231950Z, x-amzn-apigateway-api-id=fvixuu8pdb, X-Amz-Source-Arn=arn:aws:execute-api:us-east-1:451162917588:fvixuu8pdb/test-invoke-stage/GET/{proxy+}, Accept=application/json, User-Agent=AmazonAPIGateway_fvixuu8pdb, X-Amz-Security-Token=IQoJb3JpZ2luX2VjEHYaCXVzLWVhc3QtMSJGMEQCID6iyyWytqjpIbccEflk7s1qiVw9iKvWpe0LbT5pcyI7AiBe6r8TEMz4ATvlz6i0KFotp4YwcaW9CK9ZWZaahe5IyCq0AwhPEAAaDDM5MjIyMDU3NjY1MCIM8qvfeXj6wmlPGdUqKpEDV/ALuc4ecN/bWVzyjV7JWIbK3EPy+QRSHfwcCaMtD/RS7WSGIy94M6t/4PC0kF4ohRCRRfIaoleQy+r13pwItsib5tl6MIQh2W+92rxEC5WfrEiwkReW4pI6Ilgnc4GkhHb5yln53fACHZfIhL7i1guK6AKK6oGh [TRUNCATED]
Sun Jan 17 23:19:50 UTC 2021 : Endpoint request body after transformations: {"resource":"/{proxy+}","path":"/employees","httpMethod":"GET","headers":null,"multiValueHeaders":null,"queryStringParameters":null,"multiValueQueryStringParameters":null,"pathParameters":{"proxy":"employees"},"stageVariables":null,"requestContext":{"resourceId":"klp4o9","resourcePath":"/{proxy+}","httpMethod":"GET","extendedRequestId":"ZUPjeE4_oAMF9iA=","requestTime":"17/Jan/2021:23:19:50 +0000","path":"/{proxy+}","accountId":"451162917588","protocol":"HTTP/1.1","stage":"test-invoke-stage","domainPrefix":"testPrefix","requestTimeEpoch":1610925590175,"requestId":"540fb10a-6f09-454e-9eaa-15b4f8426d35","identity":{"cognitoIdentityPoolId":null,"cognitoIdentityId":null,"apiKey":"test-invoke-api-key","principalOrgId":null,"cognitoAuthenticationType":null,"userArn":"arn:aws:iam::451162917588:root","apiKeyId":"test-invoke-api-key-id","userAgent":"aws-internal/3 aws-sdk-java/1.11.901 Linux/4.9.230-0.1.ac.223.84.332.metal1.x86_64 OpenJDK_64-Bit_Server_VM/25.275-b01 java/1.8 [TRUNCATED]
Sun Jan 17 23:19:50 UTC 2021 : Sending request to https://lambda.us-east-1.amazonaws.com/2015-03-31/functions/arn:aws:lambda:us-east-1:451162917588:function:employee/invocations
Sun Jan 17 23:19:50 UTC 2021 : Received response. Status: 200, Integration latency: 173 ms
Sun Jan 17 23:19:50 UTC 2021 : Endpoint response headers: {Date=Sun, 17 Jan 2021 23:19:50 GMT, Content-Type=application/json, Content-Length=492, Connection=keep-alive, x-amzn-RequestId=63f9de04-ab75-49dc-b80b-ce3db518c421, x-amzn-Remapped-Content-Length=0, X-Amz-Executed-Version=$LATEST, X-Amzn-Trace-Id=root=1-6004c616-049f5587907c5f7d284b2b32;sampled=0}
Sun Jan 17 23:19:50 UTC 2021 : Endpoint response body before transformations: {"statusCode":500,"body":"<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<title>Error</title>\n</head>\n<body>\n<pre>Internal Server Error</pre>\n</body>\n</html>\n","headers":{"x-powered-by":"Express","access-control-allow-origin":"*","content-security-policy":"default-src 'none'","x-content-type-options":"nosniff","content-type":"text/html; charset=utf-8","content-length":"148","date":"Sun, 17 Jan 2021 23:19:50 GMT","connection":"close"},"isBase64Encoded":false}
Sun Jan 17 23:19:50 UTC 2021 : Method response body after transformations: <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Internal Server Error</pre>
</body>
</html>
Sun Jan 17 23:19:50 UTC 2021 : Method response headers: {x-powered-by=Express, access-control-allow-origin=*, content-security-policy=default-src 'none', x-content-type-options=nosniff, content-type=text/html; charset=utf-8, content-length=148, date=Sun, 17 Jan 2021 23:19:50 GMT, connection=close, X-Amzn-Trace-Id=Root=1-6004c616-049f5587907c5f7d284b2b32;Sampled=0}
Sun Jan 17 23:19:50 UTC 2021 : Successfully completed execution
Sun Jan 17 23:19:50 UTC 2021 : Method completed with status: 500
I'm using API Gateway's AWS Service integration type to add logs to the Cloudwatch Logs service using the PutLogEvents action, as described here: https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutLogEvents.html
I've successfully setup a similar type of method to add items into a DynamoDB table using the PutItem action and that worked just fine, so I'm not sure what I'm missing with this one.
I've double checked for typos and problems with my template. Have successfully used PutLogEvents using the CLI tools, so the setup seems all OK.
Here's some screenshots of my setup from the AWS dash:
Here's the mapping template I'm using:
{
"logGroupName": "FromAPI",
"logStreamName": "$input.path('$.streamName')",
"logEvents": [
{
"timestamp": $input.path('$.ts'),
"message": "$input.path('$.message')"
}
]
}
The response I get back has a 200 status code, but the following response body:
{
"Output": {
"__type": "com.amazon.coral.service#UnknownOperationException",
"message": null
},
"Version": "1.0"
}
Here's a redacted (xxx) execution log:
Execution log for request xxx
Fri Apr 19 02:28:58 UTC 2019 : Starting execution for request: xxx
Fri Apr 19 02:28:58 UTC 2019 : HTTP Method: POST, Resource Path: /log
Fri Apr 19 02:28:58 UTC 2019 : Method request path: {}
Fri Apr 19 02:28:58 UTC 2019 : Method request query string: {}
Fri Apr 19 02:28:58 UTC 2019 : Method request headers: {}
Fri Apr 19 02:28:58 UTC 2019 : Method request body before transformations: {
"streamName": "12345",
"ts": 1555641510000,
"message": "help!"
}
Fri Apr 19 02:28:58 UTC 2019 : Endpoint request URI: https://logs.xxx.amazonaws.com/?Action=PutLogEvents
Fri Apr 19 02:28:58 UTC 2019 : Endpoint request headers: {Authorization=xxx, X-Amz-Date=20190419T022858Z, x-amzn-apigateway-api-id=xxx, Accept=application/json, User-Agent=AmazonAPIGateway_xxx, X-Amz-Security-Token=xxx [TRUNCATED]
Fri Apr 19 02:28:58 UTC 2019 : Endpoint request body after transformations: {
"logGroupName": "FromAPI",
"logStreamName": "12345",
"logEvents": [
{
"timestamp": 1555641510000,
"message": "help!"
}
]
}
Fri Apr 19 02:28:58 UTC 2019 : Sending request to https://logs.xxx.amazonaws.com/?Action=PutLogEvents
Fri Apr 19 02:28:58 UTC 2019 : Received response. Status: 200, Integration latency: 38 ms
Fri Apr 19 02:28:58 UTC 2019 : Endpoint response headers: {x-amzn-RequestId=xxx, Content-Type=application/json, Content-Length=105, Date=Fri, 19 Apr 2019 02:28:58 GMT}
Fri Apr 19 02:28:58 UTC 2019 : Endpoint response body before transformations: {"Output":{"__type":"com.amazon.coral.service#UnknownOperationException","message":null},"Version":"1.0"}
Fri Apr 19 02:28:58 UTC 2019 : Method response body after transformations: {"Output":{"__type":"com.amazon.coral.service#UnknownOperationException","message":null},"Version":"1.0"}
Fri Apr 19 02:28:58 UTC 2019 : Method response headers: {X-Amzn-Trace-Id=Root=xxx, Content-Type=application/json}
Fri Apr 19 02:28:58 UTC 2019 : Successfully completed execution
Fri Apr 19 02:28:58 UTC 2019 : Method completed with status: 200
Nothing gets logged into my Cloudwatch Logs stream - the API Gateway integration request response body contains an UnknownOperationException error.
My best guess is that this request is not mapping to the PutLogEvents action for some reason. Strange that the status code is 200 in this situation.
I'm guessing it's just some typo - or an additional header that I need to send through? Any ideas?
It should work if you add the following lines at the top of your Mapping Template:
#set($context.requestOverride.header['X-Amz-Target'] = "Logs_20140328.PutLogEvents")
#set($context.requestOverride.header['Content-Type'] = "application/x-amz-json-1.1")
This is very tricky and not well documented. You can find those headers in the sample request for PutLogEvents.
I'm making a GetItem call to a DynamoDB via API Gateway integration. My request mapping is:
{
"TableName": "connected-content-dynamodb",
"Key": {
{ "id" :
{"S" : "$input.params('entity-id')"}
}
}
}
Response template is:
{ "payload" : "$input.json('$')"}
Logs that I get:
Thu Nov 22 10:31:51 UTC 2018 : Endpoint request body after transformations: {
"TableName": "connected-content-dynamodb",
"Key": {
{ "id" :
{"S" : "123"}
}
}
}
Thu Nov 22 10:31:51 UTC 2018 : Sending request to https://dynamodb.eu-west-1.amazonaws.com/?Action=GetItem
Thu Nov 22 10:31:51 UTC 2018 : Method response body after transformations: {"__type":"com.amazon.coral.service#SerializationException"}
Thu Nov 22 10:31:51 UTC 2018 : Method response headers: {X-Amzn-Trace-Id=Root=1-5bf68597-8d22f7ca52c6af2aded083e0, Content-Type=application/json}
Thu Nov 22 10:31:51 UTC 2018 : Successfully completed execution
Thu Nov 22 10:31:51 UTC 2018 : Method completed with status: 404
Any ideas whats wrong? Or how to debug it?