首页 > 解决方案 > 超时时在 api 网关响应正文中返回 lambda 的 context.requestId

问题描述

使用 ApiGateway Lambda 集成时,我需要将 lambda 的上下文请求 ID 返回给客户端。我在 ApiGateway -> Gateway Responses -> Integration Timeout -> Response Templates 中试过这个

{ "message":$context.error.messageString, "request_id": $context.awsEndpointRequestId, "request_id_2": $context.requestId }

但是,响应正文中仅显示 $context.requestId,而不是 $context.awsEndpointRequestId。

如果 ApiGateway 超时, awsEndpointRequestId (我假设它是 lambda 上下文请求 id )是否不可用?

标签: amazon-web-servicesaws-lambdaaws-api-gateway

解决方案


推荐阅读