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

时间:2018-11-12 03:47:21

标签: amazon-web-services api aws-lambda aws-api-gateway

我在API网关中有 POST 方法,该方法接受从主体参数传递的数据。

enter image description here

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

enter image description here

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

1 个答案:

答案 0 :(得分:1)

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

请求:

import pandas as pd
import glob

frames = []

for f in glob.glob("/home/humblefool/Dropbox/MSc/MSc Project/Data-Concentrated Solar Power-NamPower/Arandis 2016/2016 01 January/*.xlsx"): #path to datafiles and using glob to select all files with .xlsx extension
    df = pd.read_excel(f).assign(file_name=f)
    # Add date column for sorting later
    df['date'] = pd.to_datetime(df.file_name.str.extract(r'(\d{4}-\d{2}-\d{2})', expand=False), errors='coerce')
    frames.append(df)

all_data = pd.concat(frames, ignore_index=True).sort_values('date')

映射:

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