2 Respostas
- Mais recentes
- Mais votos
- Mais comentários
0
Hello.
If you look at the Lambda log, the element "queryStringParameters" contains parameters.
Therefore, you can check the "Username" by getting the parameters with "event.get('queryStringParameters')" as shown below.
https://docs.aws.amazon.com/lambda/latest/dg/urls-invocation.html
import json
def lambda_handler(event, context):
param = event.get('queryStringParameters')
print(param['Username'])
If you include the request body, it will be included in an element called "body", so you can retrieve it as follows.
import json
def lambda_handler(event, context):
print(event)
param = event.get('queryStringParameters')
print(param['Username'])
body = event.get('body')
print(json.loads(body)['Username'])
A sample request that includes a request body looks like this:
curl 'https://test.lambda-url.ap-northeast-1.on.aws/?Username=Elvis' -H 'content-type: application/json' -d '{ "Username": "test" }'
0
Thank you. Best answer I could not find anywhere online. You're the best!
respondido há um ano
Conteúdo relevante
- feita há 2 meses
- feita há 2 meses
- feita há 2 meses