gpt4 book ai didi

amazon-web-services - 如何从 Api Gateway 集成请求映射模板映射数组或对象?

转载 作者:行者123 更新时间:2023-12-04 15:52:37 25 4
gpt4 key购买 nike

我在 API 网关中有 POST 方法,它接受从正文参数传递的数据。

enter image description here

从 API 网关,我设法获取了用户名和 uuid,但我在获取 traveledCities 时遇到了错误。如何映射从正文参数传递的数组或对象

enter image description here

我从 $inputRoot.traveledCities 第 5 行收到错误

最佳答案

您必须直接使用数组字段定义模板。这里有一个例子:

请求:

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

映射:

#set($inputRoot = $input.path('$'))
{
"query": "$input.params('query')",
"id": "$inputRoot.id",
"list": $inputRoot.list
}

关于amazon-web-services - 如何从 Api Gateway 集成请求映射模板映射数组或对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53255712/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com