【发布时间】:2023-04-02 20:31:01
【问题描述】:
我有一个已成功发布为 AWS Lambda 函数的 C# 方法。它看起来像这样:
public class MyClass
{
public async Task<APIGatewayProxyResponse> Test(APIGatewayProxyRequest request, ILambdaContext context)
{
return new APIGatewayProxyResponse
{
Body = "Body: " + request.Body
+ Environment.NewLine
+ "Querystring: " + (request.QueryStringParameters == null ? "null" : string.Join(",", request.QueryStringParameters.Keys)),
StatusCode = 200
};
}
}
我已通过 Web 界面执行以下操作来配置我的 API 网关:
- 创建了新的 API
- 创建了一个名为“myclass”和路径“/myclass”的新资源
- 为资源创建了一个新的 GET 方法,使用“Lambda 函数”作为集成类型,并指向我的 Lambda 函数。
我希望能够像这样调用我的 Lambda 函数(无需在请求中传递任何指定的标头): https://xxx.execute-api.us-east-2.amazonaws.com/prod/myclass?paramA=valueA¶mB=valueB
我不确定如何让我的查询字符串参数传递给 lambda 函数。无论我尝试什么,request.QueryStringParameters 始终为空。
这里的正确程序是什么?
【问题讨论】:
标签: c# aws-lambda aws-api-gateway