Brandon Miller
Brandon Miller

Reputation: 357

How to embed parameters into AWS Lambda GET request?

So say my request url to get all the Users at Location 4 is something like

./Location/Users?locationId=4 or ./Location/Users/4

but we would of course prefer to structure the request url like this:

./Location/4/Users

however, every single AWS help document and help question I can find on here uses the first syntax, so I am unsure how to proceed. It seems like there should be a way to do this, as it is a very common design pattern, but AWS seems to lock you in to only being able to append to the ./Users path instead of being able to prepend the argument.

I think configuring API Gateway to accept a parameter in this way would have to change the way they display the resources here

To be clear, the first request syntax is working, but I'm not sure how to adjust the syntax to a more industry-standard way of doing it since embedding the parameter in the middle of the url instead of at the end would fundamentally change the Amazon Resource Name.

There's probably something simple that I'm missing here though.

Upvotes: 0

Views: 83

Answers (1)

Arun Kamalanathan
Arun Kamalanathan

Reputation: 8603

Api gateway indeed supports URl like Location/{locationId}/Users. You first need to create locationId as a child resource and then create users as a child resource under that.

Steps

  • Click Location, and goto actions and click create resource.
  • fill the details of your new resource

    resource name - give a meaningful name

    resource path - {locationId}

  • repeat the same to add Users under LocationId

Upvotes: 1

Related Questions