I can generate an event like this in SAM
sam local generate-event apigateway aws-proxy --method GET --path document --body "{"test": "1", "tests2": "2"}" > local-event.json
But this does not really help me because I do not send a body to my endpoint but I send queryparameters like this:
localhost:3000/path?test=1&test2=2
How can I generate an event with query string parameters in SAM for local testing instead of using curl/testing against the local api gateway.
To send query string parameters using sam local invoke
:
sam local generate-event apigateway aws-proxy --method GET > local-event.json
local-event.json
, there should be an object key called "queryStringParameters"
. Simply add "key": "value"
pairs to this object. Save.sam local invoke -e local-event.json
Source: https://seanjziegler.com/how-to-build-an-api-with-aws-lambda-and-api-gateway-using-aws-sam/#5-testing-the-api-with-sam-local-
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With