Reputation: 945
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.
Upvotes: 4
Views: 5429
Reputation: 861
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
Upvotes: 11