Could someone please explain the difference between accessing Lambda via the test gateway API (proxy) and CLI?
When I make a request via curl, only the body content is sent to the Lambda function’s event.
curl --location --request POST 'https://xxxxx.execute-api.eu-central-1.amazonaws.com/live/request'
--header 'Content-Type: application/json'
--data '{
"date": "2025-02-14",
"time": "15:00",
"quantity": 101
}'
event content in lambda function:
{
"date": "2025-02-14",
"time": "15:00",
"quantity": 101
}
But when I make a request through the test within the gateway API itself, I can see more information, including the invoked method type like POST.
{
'resource': '/request',
'path': '/request',
'httpMethod': 'POST',
'headers': None,
'multiValueHeaders': None,
'queryStringParameters': None,
'multiValueQueryStringParameters': None,
'pathParameters': None,
'stageVariables': None,
'requestContext': {
'resourceId': 'xxxxx',
'resourcePath': '/request',
'httpMethod': 'POST',
'extendedRequestId': 'xxxxxxxxxxx',
'requestTime': '11/May/2024:08:52:23 +0000',
'path': '/request',
'accountId': '11111111111',
'protocol': 'HTTP/1.1',
'stage': 'test-invoke-stage',
'domainPrefix': 'testPrefix',
'requestTimeEpoch': 1715417543338,
'requestId': 'xxxxxxx-xxxxx',
'identity': {
'cognitoIdentityPoolId': None,
'cognitoIdentityId': None,
'apiKey': 'test-invoke-api-key',
'principalOrgId': None,
'cognitoAuthenticationType': None,
'userArn': 'arn:aws:sts::xxxxxxxxx:assumed-role/xxxxxxx/xxxxxx',
'apiKeyId': 'txxxxxxx',
'userAgent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36',
'accountId': 'xxxxxxxx',
'caller': 'xxxxx',
'sourceIp': 'xxxxx',
'accessKey': 'xxxxxx',
'cognitoAuthenticationProvider': None,
'user': 'xxxxxxxxxx'
},
'domainName': 'xxxxx',
'apiId': 'xxxxxxx'
},
'body': '{n "date": "2025-02-14",n "time": "15:00",n "quantity": 101n}',
'isBase64Encoded': False
}
Why does this happen? And to get all this info via curl?