我在这里看到了类似问题的答案。但这对解决我的问题没有帮助
当我在 Postman 上执行 GET 请求时,我得到“GET TEST”响应,但是当我执行任何其他类型的请求时,我得到“API 网关:内部服务器错误”
我的资源设置了各种方法类型
我有一个带有以下代码的 lambda 函数(我删除了游标/数据库凭证代码):
import json
import mysql.connector
def lambda_handler(event, context):
http_method = event.get('httpMethod')
response = None
if http_method == "GET":
response = getFunction(cursor, event)
elif http_method == "POST":
response = postFunction(cursor, event)
elif http_method == "PUT":
response = putFunction(cursor, event)
elif http_method == "DELETE":
response = deleteFunction(cursor, event)
return {
"statusCode": 200,
"body": json.dumps({
"event": event,
"response": response
})
}
def getFunction(cursor, event):
return "GET TEST"
def postFunction():
return "POST TEST"
def putFunction():
return "PUT TEST"
def deleteFunction():
return "DELETE TEST"
天哪,我是个菜鸟。
我查看了 Cloudwatch 日志,发现我的函数没有参数。