- Newest
- Most votes
- Most comments
Invoking a function using the AWS Toolkit in your IDE bypasses the Function URL and thus invokes the Lambda service directly. So, no integrations are involved. For Function URL, there is an integration involved, so you need to develop your function taking that into account.
Please refer to the Developer Guide.
When a client calls your function URL, Lambda maps the request to an event object before passing it to your function.
The request and response event formats follow the same schema as the Amazon API Gateway payload format version 2.0.
That means, you have to change your function signature so that it can accept a request object in the API Gateway payload v2.0 format. The corresponding type is Amazon.Lambda.APIGatewayEvents.APIGatewayHttpApiV2ProxyRequest
from the assembly Amazon.Lambda.APIGatewayEvents
.
Refactor your function in this way:
using Amazon.Lambda.APIGatewayEvents; //... public string FunctionHandler(APIGatewayHttpApiV2ProxyRequest request, ILambdaContext context) { Console.WriteLine("Hello there"); Console.WriteLine("Input: " + request.Body); return request.Body.ToUpper(); }
Now you can invoke your Lambda using the Function URL via Postman or any other client. In this case, since the request body is expected to be plain text, don't forget to specify this in the request's header as Content-Type: text/plain
. Also note that you will need to change the request payload template in AWS Toolkit in your IDE to API Gateway AWS Proxy
when invoking the function - this is because you've changed the handler signature.
Relevant content
- asked 3 months ago
- asked 5 months ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 4 years ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 2 years ago
Many thanks Dmitry, I will try this later today and let you know how I got on.