How to read the Client Context sent with a POST request to the Lambda API Invoke?

0

Hi community!

I want to send a POST request using the Lambda API's Action "Invoke" (Here's the docs on how to configure this API call: https://docs.aws.amazon.com/lambda/latest/dg/API_Invoke.html#API_Invoke_RequestSyntax). The problem is that I also want to send some base64-encoded client context ( e.g {"message": "Hello World"}), but I don't know how to read this data from my lambda function code. I thought it was supposed to be found in the "context" object of my lambda handler, but seems it's not.

preguntada hace un año611 visualizaciones
1 Respuesta
0

Lambda functions receive two parameters: Event object and Context object. The event object contains all the information about why it was triggered. The context object contains different run-time information, e.g., request ID. Most customers don't use the context object.

When you invoke the function using the Invoke API, the event object will contain the payload that you send in the API call. Usually clients will not invoke the function directly. They will use other services to invoke the function, e.g., API Gateway to expose a REST API that invokes the function for every API call. In this case, when API GW invokes the function, the payload will include the entire REST request, including all the headers, body, etc.

profile pictureAWS
EXPERTO
Uri
respondido hace un año

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas