23

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:

enter image description here

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

Chacko
  • 1,506
  • 1
  • 20
  • 42
AleMal
  • 1,977
  • 6
  • 24
  • 49

1 Answers1

43

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.

Aaron Frary
  • 906
  • 1
  • 13
  • 24
Liam
  • 545
  • 4
  • 11
  • Thanks a lot! read error carefully i see that error seems related to check method calL :ck_app = check(event['calID'], event['datada'], event['dataa']) that return a single parameter. Is it possible?? – AleMal Dec 20 '17 at 15:13
  • hi there, can't really help you with that i am afraid. i am just custom with lambda but have no idea how the check function works. Would suggest to make a new question to find it out. – Liam Dec 21 '17 at 10:05
  • @AleMal You just need to pass string using json.dumps in "body" – Abhigna Nagaraja Dec 22 '17 at 01:54