简体   繁体   English

字符串索引必须是整数aws lambda api

[英]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.

相关问题 AWS lambda 响应错误:字符串索引必须是整数(文本) - AWS lambda response ERROR: string indices must be integers (Textract) Python lambda 表达式 - 字符串索引必须是整数 - Python lambda expression - string indices must be integers 字符串索引必须是 api 中的整数,包装在 Python 中 - String indices must be integers in api wrapping in Python 字符串索引必须是整数,而不是str-API - String Indices must be integers, not str - API 类型错误:字符串索引必须是整数,使用 Pandas 与 lambda 一起应用 - TypeError: string indices must be integers using pandas apply with lambda 格式不正确的Lambda代理响应:字符串索引必须为整数 - Malformed Lambda proxy response: string indices must be integers 类型错误:字符串索引必须是整数,应用 Pandas 和 lambda - TypeError: string indices must be integers with Pandas apply and lambda AWS CLI坏了吗? 获取“字符串索引必须为整数” - aws cli broken? Get “string indices must be integers” Boto3 AWS TypeError:字符串索引必须是整数 - Boto3 AWS TypeError: string indices must be integers 解析 aws sns 响应时,字符串索引必须是整数错误 - string indices must be integers error when parsing aws sns response
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM