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

1
  • 1
    Have you tried just surronding it with [], like ["$inputRoot.traveledCities"] ? Commented Nov 12, 2018 at 12:42

1 Answer 1

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
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.