【问题标题】:The incoming event is not a valid request from Amazon API Gateway or an Application Load Balancer传入事件不是来自 Amazon API Gateway 或 Application Load Balancer 的有效请求
【发布时间】:2021-08-08 15:48:39
【问题描述】:

我使用 AWS API Gateway 创建了一个 REST API。我有一个触发 Lambda 函数的 GET 方法,但我无法获得所需的响应。我正确配置了查询参数等,但在 Lambda 日志中我看到了这一点。

com.amazonaws.serverless.exceptions.InvalidRequestEventException: The incoming event is not a valid request from Amazon API Gateway or an Application Load Balancer

2021-05-19T15:37:38.003+04:00   at com.amazonaws.serverless.proxy.internal.servlet.AwsProxyHttpServletRequestReader.readRequest(AwsProxyHttpServletRequestReader.java:48)

2021-05-19T15:37:38.003+04:00   at com.amazonaws.serverless.proxy.internal.servlet.AwsProxyHttpServletRequestReader.readRequest(AwsProxyHttpServletRequestReader.java:30)

2021-05-19T15:37:38.003+04:00   at com.amazonaws.serverless.proxy.internal.LambdaContainerHandler.proxy(LambdaContainerHandler.java:201)

我错过了什么?提前谢谢你。

【问题讨论】:

    标签: amazon-web-services aws-lambda aws-api-gateway api-gateway


    【解决方案1】:

    在本地运行 lambdas 时,您需要定义触发它的事件。
    例如: sam local invoke --event tst\event.json 其中 event.json 基本上就是你传递的 http 参数。

    {
      "httpMethod": "GET",
      "path": "/",
    }
    

    要为http请求创建事件json模板文件,可以使用:sam local generate-event apigateway aws-proxy

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-01-21
      • 1970-01-01
      • 2021-11-05
      • 2018-05-27
      • 2020-08-03
      • 2020-11-16
      • 2022-06-17
      • 2017-01-14
      相关资源
      最近更新 更多