-1

I'm new to aws lambda, I created a function writen in python, i have aws api gateway as a trigger to my function.

the runtime is python 3.11

Now! here's the problem that i can't even explain:

import json

def lambda_handler(event, context):
    # TODO implement
    query = event.get('queryStringParameters', {})
    
    #that line causes the problem
    challeng = query.get('challenge', None)
    
    return {
        'statusCode':200,
        'body': 'xyz'
    }

and since lambdas doesn't have logs to trace the issue in the code (if any)

1
  • 1
    can you share more info -- what exactly is a problem? error message? lambdas can log or send data via print statements to the cloudwatch Commented Nov 28, 2023 at 19:36

2 Answers 2

1

You should be able to access those parameters with the following syntax


import json

def lambda_handler(event, context):
    # TODO implement
    query = event["queryStringParameters"]
    
    #that line causes the problem
    challenge = query["challenge"]
    
    return {
        "statusCode": 200,
        "headers": { "content-type": "application/json"},
        "body": json.dumps(challenge)
    }
Sign up to request clarification or add additional context in comments.

1 Comment

0

as i expected the issue wasn't in the code.

i simply deleted the function and created another one with the same code, guess what? it worked!

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.