How can I post a json object to aws lambda function through aws API gateway ?
p.s.- My goal is to write the lambda function in python and then post it to aws SQS.
<
Yes you can,
If you trigger the Lambda function from API Gateway using the Lambda Proxy integration the request will call the function with a payload that looks like that below. As you can see all you need to do is parse the JSON body attribute.
{
"resource": /path",
"path": "/path",
"httpMethod": "PUT",
"headers": {
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate, sdch, br",
"Accept-Language": "en-US,en;q=0.8,pl;q=0.6,en-GB;q=0.4",
"Cache-Control": "no-cache",
"CloudFront-Forwarded-Proto": "https",
"CloudFront-Is-Desktop-Viewer": "true",
"CloudFront-Is-Mobile-Viewer": "false",
"CloudFront-Is-SmartTV-Viewer": "false",
"CloudFront-Is-Tablet-Viewer": "false",
"CloudFront-Viewer-Country": "PL",
"Content-Type": "application/json",
"DNT": "1",
"Host": "api.stockflare.com",
"Origin": "http://localhost:3000",
"Pragma": "no-cache",
"Referer": "http://localhost:3000/databank",
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36",
"Via": "1.1 XXXXX.cloudfront.net (CloudFront)",
"X-Amz-Cf-Id": "XXXXXX==",
"X-Amzn-Trace-Id": "Root=XXXXXX",
"X-Forwarded-For": "XXXXX",
"X-Forwarded-Port": "443",
"X-Forwarded-Proto": "https"
},
"queryStringParameters": null,
"pathParameters": null,
"stageVariables": null,
"requestContext": {
"path": "/path",
"accountId": "XXXXX",
"resourceId": "p0flbp",
"stage": "v1",
"requestId": "XXXXX",
"identity": {
"cognitoIdentityPoolId": null,
"accountId": null,
"cognitoIdentityId": null,
"caller": null,
"apiKey": "",
"sourceIp": "XXXXXX",
"accessKey": null,
"cognitoAuthenticationType": null,
"cognitoAuthenticationProvider": null,
"userArn": null,
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36",
"user": null
},
"resourcePath": "/path",
"httpMethod": "PUT",
"apiId": "XXXXXX"
},
"body": "{\"fields\":[\"forecast_pe\"],\"countries\":[\"_all\",\"amer\",\"apac\",\"emea\"],\"sectors\":[\"50\",\"51\"]}",
"isBase64Encoded": false
}