I have an answer method that looks like this for my lambda functions:
def respond(err, res=None):
return {
'statusCode': 400 if err else 200,
'body': json.dumps(err) if err else json.dumps(res),
'headers': {
'Access-Control-Allow-Headers': 'content-type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token',
'Access-Control-Allow-Methods': 'POST, GET, DELETE',
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Credentials': True,
'Content-Type': 'application/json',
},
}
When I test my endpoint with an OPTIONS request from Postman, I get an internal server 500 error. If I test it from the Gateway API console, I will get this additionally:
Execution log for request test-request
Wed Jul 05 14:25:26 UTC 2017 : Starting execution for request: test-invoke-request
Wed Jul 05 14:25:26 UTC 2017 : HTTP Method: OPTIONS, Resource Path: /login
Wed Jul 05 14:25:26 UTC 2017 : Method request path: {}
Wed Jul 05 14:25:26 UTC 2017 : Method request query string: {}
Wed Jul 05 14:25:26 UTC 2017 : Method request headers: {}
Wed Jul 05 14:25:26 UTC 2017 : Method request body before transformations:
Wed Jul 05 14:25:26 UTC 2017 : Received response. Integration latency: 0 ms
Wed Jul 05 14:25:26 UTC 2017 : Endpoint response body before transformations:
Wed Jul 05 14:25:26 UTC 2017 : Endpoint response headers: {}
Wed Jul 05 14:25:26 UTC 2017 : Execution failed due to configuration error: Output mapping refers to an invalid method response: 200
Wed Jul 05 14:25:26 UTC 2017 : Method completed with status: 500
I'm not quite sure what I'm doing wrong. I seem to be returning all the correct headers. Any help is appreciated.
source
share