Python 3.x “;KeyError:';记录'”;在AWS S3中-Lambda触发器

Python 3.x “;KeyError:';记录'”;在AWS S3中-Lambda触发器,python-3.x,aws-lambda,Python 3.x,Aws Lambda,使用此代码后,我收到一个错误,我使用了Postman来查找错误 import json from botocore.vendored import requests URL = "https://api.telegram.org/bot<token>/sendMessage?text=" def lambda_handler(event, context): body = event["body"] url = URL + body + "&chat_id

使用此代码后,我收到一个错误,我使用了Postman来查找错误

import json
from botocore.vendored import requests

URL = "https://api.telegram.org/bot<token>/sendMessage?text="

def lambda_handler(event, context):
    body = event["body"]
    url = URL + body + "&chat_id=<chat-id>"
    requests.get(url)
    return {
        'statusCode': 200
    }
您需要在AWS API中配置集成请求。点击 身体映射模板。然后将映射模板集内容类型添加到 应用程序/json然后编辑生成的映射模板:

参考:

{
    "errorMessage": "'body'",
    "errorType": "KeyError",
    "stackTrace": [
        [
            "/var/task/lambda_function.py",
            7,
            "lambda_handler",
            "body = event[\"body\"]"
        ]
    ]
}