[英]string indices must be integers aws lambda api
def lambda_handler(event, context):
"idsA=event['items'][0]['ids']"
When i want call with Python the JSON object items which contains arrays ids.. in aws lambda, from API, It returns this error: 当我想用Python调用aws lambda中包含数组ID ..的JSON对象项时,会从API返回以下错误:
"string indices must be integers"`
I think the problem can be in COnfigure test event : 我认为问题可能出在COnfigure测试事件中:
{
"ids": "ids",
"contents": "contents",
"ResultID": "ResultID",
"QueryID": "QueryID",
"nR": "nR",
"items": "ids"
}
or in API getaaway in JSON body mapping template: 或在JSON主体映射模板中的API getaaway中:
{
"items": [
#foreach($elem in $input.params('items').split(','))
{
"ids": "$elem.ids",
"contents": "$elem.contents"
}#if($foreach.hasNext),#end
#end
],
"QueryID": "$input.params('QueryID')",
"nR": "$input.params('nR')"
}
It sounds like in your test event items is supposed to be a JSON array of objects: 听起来您的测试事件项目应该是对象的JSON数组:
{
"ResultID": "ResultID",
"QueryID": "QueryID",
"nR": "nR",
"items": [
{
"ids": [1, 2, 3],
"contents": ["content1", "content2"]
}
]
}
... but I think there may be a template mapping issue here as well. ...但是我认为这里也可能存在模板映射问题。 What does a raw request to API gateway look like? 对API网关的原始请求是什么样的?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.