3

I have POST method in API Gateway that accepts the data passed from body params.

enter image description here

From the API Gateway, I managed to get the userName and uuid, but I'm having an error getting the traveledCities. How can I map an array or an object passed from body params

enter image description here

I'm getting an error from $inputRoot.traveledCities line 5

AllenC
  • 2,754
  • 1
  • 41
  • 74

1 Answers1

3

You have to define the template directly with the array field. Here an example:

Request:

POST apigateway/stage/resource?query=test
{
  "id": "id",
  "list": [1,2,3,4]
}

Mapping:

#set($inputRoot = $input.path('$'))
{
  "query": "$input.params('query')",
  "id": "$inputRoot.id",
  "list": $inputRoot.list
}
wodka
  • 1,320
  • 10
  • 20