我的场景是当我的 Lambda 函数的 Api 端点被命中时,使用 post 变量,我希望我的 Lambda 调用数据库连接并获得一些结果。
所以第一步是创建一个 API 网关端点,我在创建带有参数的 POST 方法时遇到问题
这是我到目前为止所做的:
控制台中的响应如下
我如何在这里为 api 创建参数?我如何测试它?我有我的 准备好 lambda 函数,它接受一个字符串作为输入并返回一个字符串作为响应 .
有人可以指导我下一步..
最佳答案
您可以查看 Create and Test a POST Method
你没有在 lambda 定义中提到参数,参数会直接从请求中获取(所以以后如果你改变你的 lambda 代码来获取新的参数,你不需要改变配置
去测试 :
In the Method Execution pane, in the Client box, and then choose TEST.
Expand Request Body, and type the following:
{ "name": "User" <or any other parameter that you expect> }
Choose Test. If successful, Response Body will display the reply from your lambda execution
例如这里我有一个示例post api
所以再次对于 POST API,您没有定义参数
如果您正在执行 GET API,您将定义查询参数
关于amazon-web-services - AWS API Gateway - 如何创建 post 方法并对其进行测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37459779/