AnomalyInnovations / aws-api-gateway-cli-test

A simple CLI to test API Gateway endpoints with IAM authorization
MIT License
120 stars 29 forks source link

How to pass queryparameters #14

Closed j-waaang closed 4 years ago

j-waaang commented 5 years ago

Hey I'm trying to pass query parameters to the request. After looking up the aws amplify docs I've come up with this which unfortunately doesn't work. --params "{\"queryStringParameters\":{\"offset\":\"10\"}}"

The event my lambda function recieves still has no query parameters queryStringParameters: null,

Simply entering my api url into the browser and adding ?offset=10 works. queryStringParameters: { offset: '10' },

So I guess my setup in serverless.yaml should be correct. And I'm entering the parameters wrong inside my console. I'm using cmd on windows btw.

j-waaang commented 5 years ago

Solved this by passing the parameters in additional parameters instead and using the name queryParams --additional-params "{\"queryParams\":{\"offset\":\"10\"}}"

However the readme of this project says to put the querystring inside the params. Is this a mistake? params The API params (path, header, querystring, etc) as a JSON string. Defaults to '{}'.

jayair commented 5 years ago

Yeah you might be right there. It should be passed through the additional-params. Thanks for letting us know.

petewilcock commented 4 years ago

Please can you add a simple example like this to the readme for queryParams? Had to search here after struggling in pain for a bit :)

jayair commented 4 years ago

Added - https://github.com/AnomalyInnovations/aws-api-gateway-cli-test/commit/5a6b6435c2fef0723feadaeb2f48a419c28c6f07.