I’m trying to set up API Gateway v1 and I keep getting this 502 error when sending POST requests with a JSON body to it:

2024-02-14T15:22:32.352  WARN --- [   asgi_gw_3] l.s.apigateway.integration : Lambda output should follow the next JSON format: { "isBase64Encoded": true|false, "statusCode": httpStatusCode, "headers": { "headerName": "headerValue", ... },"body": "..."}

It works fine when I send any GET requests. It’s also worth mentioning that I don’t have this issue when testing it with sam local start-api.

Hello @hkaiser,

When the IntegrationType of an API Gateway V1 method is set to AWS_PROXY, the lambda must respond with a specific format, as specified in the AWS documentation:

Could you maybe share how you are setting up your API, so that we could troubleshoot?
Thanks

1 Like

It turns out that the error might be originating from inside my lambda code when I checked the CloudWatch logs. I was only looking at the logs when I ran localstack logs. I was under the impression that I would be able to see the logs by my lambdas this way. But I now know what error I need to fix. It’s giving me a ‘Forbidden’ error when I attempt to publish an MQTT message using the AWS IoT Data SDK. Since I don’t have a pro account yet, I’m attempting to use an AWS resource outside of localstack using different AWS credentials.