Is it possible to define path params in AWS Mobile Hub API?

77 views Asked by At

I would like to define path params in API generated by AWS Mobile Hub but I can't see the way how I could do this using MH API configuration page. There you can define API name + paths but it is not possible to use brackets like placeholders ie. {userId} within subpath during the API creation. As an example, I've created users API with items subpath and lets say I would like to achieve API path like this /users/item/{userId}. When I've created path like /items it is possible to invoke from test module /users/items/1 but this 1 is not mapped as path params (it can't be as I haven't defined it as path params anywhere) and this value is delivered to lambda as path request attribute instead of path param. I would like to use path params instead.

1

There are 1 answers

2
Andrew C On BEST ANSWER

When you add an API with a path in the AWS Mobile Hub Cloud Logic feature, it uses a greedy path variable in the API definition to pass through all path parameters to your AWS Lambda function. You don't need to explicitly define your parameters because any/all parameters will be passed through automatically.

For example, if your path is "items" then requests will pass through to AWS Lambda for /items, /items/123, /items/123/456/789, etc.. They all pass through to your AWS Lambda function.