Search code examples
amazon-web-servicesaws-lambdahttp-status-codesapi-gateway

AWS API Gateway returning different status via Postman to Method Test


I have an AWS Lambda integrated into API Gateway. The lambda is current just returning an error:

exports.handler = (event, context, callback) => {
  context.fail(JSON.stringify({
    status: 500,
    errors: 'This is definitely the same endpoint.'
  }));
};

I have added an HTTP status 500 response in method response of API Gateway, and I have mapped an integration response using regex *"status":500.* to the 500 response.

When I test this using the Method Test functionality in AWS, I get the 500 response I expect:

AWS Method Test Response

But when send command to the endpoint with Postman, I get a 200 status:

Postman response

How can this be? The Method Test seems to suggest my Integration Response and Method Response setups are correct, and I have my regex set up correctly, but what am I missing between the API Gateway and the rest of the world that would produce this different result?


Solution

  • Have you tried Deploying the API? Maybe a redeployment might fix the issues.