Posting from AWS-API Gateway to Lambda

前端 未结 3 874
遇见更好的自我
遇见更好的自我 2020-12-29 11:19

I have a simple C# Aws Lambda function which succeeds to a test from the Lambda console test but fails with a 502 (Bad Gateway) if called from the API Gateway (which i gener

3条回答
  •  无人及你
    2020-12-29 11:37

    I also lost a lot of time trying to get a "Path Parameter" passed in on a Get method. For example, if you had a path such as

    /appsetting/123

    ... then you'd have something configured like

    By specifying the resource "appid" as {appid} it tells the API Gateway to capture this as a path variable.

    One key discovery I found was that by posting in the body of a POST type action, my Lambda would work. Reading around on some other threads, I then discovered I can transform my path variable into a body of the GET action by:

    1. Selecting the GET value (as pictured)
    2. Clicking Integration Request
    3. Creating a mapping template as shown below

    Now when I test, I'm able to plug in my appid value in only and get the proper result. Hope this helps someone.

提交回复
热议问题