Defining Path with query string Serverless HTTP API (API Gateway v2)

How can I define the path in serverless.yml with more than one query parameter using HTTP API (API Gateway v2) so that the endpoint looks like the following:

https://example.com/rest/endpoint?id=$id&tag=$tag

serverless.yml

 dfsPostback: 
    handler:  handlers/result.main 
    events:
      - httpApi:
          path: /dfs-pingback  // need help here 
          method: get

I tried with following but it did not work.

path: /dfs-pingback?id={id}&tag={tag}

You don’t need to define query parameters in serverless.yml file. You can just access that info in your handler event.

This is ok:

 dfsPostback: 
    handler:  handlers/result.main 
    events:
      - httpApi:
          path: /dfs-pingback 
          method: get

Then in your result.main function you can access to query parameters in event.queryStringParameters object

1 Like