如果我設置標題X-Amz-Invocation-Type:'Event',則調用是異步完成的,但如亞馬遜文檔所述(https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-set-up-simple-proxy.html#api-gateway-simple-proxy-for-lambda-output-format),當使用代理Lambda集成,lambda函數必須返回這樣的一個好格式的響應:API網關 - Lambda代理集成和異步調用
callback(null, {"statusCode": 200, "body": "results"})
隨着lambda函數異步調用,API網關從來沒有得到答案,然後返回502錯誤網關的錯誤,而不是200個OK狀態。
下面招搖配置的摘錄:
"/myFunc": {
"post": {
"parameters": [
{
"name": "myparam",
"in": "query",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "200 response"
}
},
"x-amazon-apigateway-request-validator": "Validate query string parameters and headers",
"x-amazon-apigateway-integration": {
"responses": {
"default": {
"statusCode": "200"
}
},
"uri": "arn:aws:apigateway:ap-northeast-1:lambda:path/2015-03-31/functions/arn:aws:lambda:ap-northeast-1:idAccount:function:myFunc/invocations",
"passthroughBehavior": "when_no_match",
"httpMethod": "POST",
"type": "aws_proxy",
"requestParameters": {
"integration.request.header.X-Amz-Invocation-Type": "'Event'"
}
}
}
}
有沒有辦法把它的工作?
LAMBDA,本身應該回歸到一個異步調用一個結構良好的反應......至少,那是什麼[這裏](http://docs.aws.amazon.com/apigateway/latest /developerguide/integrating-api-with-aws-services-lambda.html)似乎表明。 –
他們在本教程中未使用Lambda代理集成... 如果我不使用Lambda代理集成,但我必須使用正文模板來傳遞請求參數和階段變量 – Alexandre
@Alexandre i我只是面臨同樣的問題。你設法解決這個問題嗎? – Pawel