简体   繁体   中英

Malformed Lambda proxy response from AWS API Gateway calling a Lambda

In my project i create a py function for check and modify my google calendar like this:

def main(event, context):

    ck_app = check(event['calID'], event['datada'], event['dataa'])

    if not ck_app: insert(event['calID'], event['datada'], event['dataa'], event['email'])

    return {
        "isBase64Encoded": False,
        "statusCode": '200',
        "headers": {},
        "body": {'input': event,
                 'busy': ck_app,
                 'guest_email': event['email']}   
    }

when i test it on my lambda all done, but whe i create an API from lambda:

在此输入图像描述

and test it the result is:

Wed Dec 20 13:35:58 UTC 2017 : Execution failed due to configuration error: Malformed Lambda proxy response Wed Dec 20 13:35:58 UTC 2017 : Method completed with status: 502

Thanks in advance

API Gateway expects a json body so you should use something like this

import json
return {
    'statusCode': 200,
    'body': json.dumps({'input': event,
                        'busy': ck_app,
                        'guest_email': event['email']})
}

Hope this helps you forward.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM