- Newest
- Most votes
- Most comments
Assuming you're using a lambda proxy integration from api gateway, the output dict documentation is here: https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html#api-gateway-simple-proxy-for-lambda-output-format
You have an = in you result dict, which should be a syntax error.
As an aside, the location header usually isn't much use with a 2xx response. Usually needs a 3xx.
The = in the dict is a red herring caused by careless simplification of the code for illustration.
201 CREATED response usually contain a location header. (See for example: https://restfulapi.net/http-status-201-created/)
Again, the fact the a given HTTP code usually has a location header or not is mostly irrelevant. The problem is that the code works with lambda run locally but not on AWS.
Well, at this point I'd say there's no easy answer. There could be some difference in how sam is set up as opposed to api gateway and lambda. There could be some other problem. If you can, please post the (suitably redacted) lambda and the api gateway config?
I created a simplified version and I found the problem:
- When run locally, the header is Location (Uppercase L)
- When run when deployed, the header is location (lowercase L)
The API gateway changes the headers case. The test I ran was too strict and expected the case not to change.
Relevant content
- Accepted Answerasked 4 years ago
- asked 3 months ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated a year ago