how to get return response from AWS Lambda function
A 202
response means Accepted
. It is a successful response but is telling you that the action you have requested has been initiated but has not yet completed. The reason you are getting a 202
is because you invoked the Lambda function asynchronously. Your InvocationType
parameter is set to Event
. If you want to make a synchronous call, change this to RequestResponse
.
Once you do that, you can get the returned data like this:
data = invoke_response['Payload'].read()
try: data = invoke_response['Payload'].read()
read() because it is a StreamingBody object
<botocore.response.StreamingBody object at 0x110b91c50>
It is in the boto3 docs. You can find more details about this here: https://boto3.amazonaws.com/v1/documentation/api/latest/guide/resources.html#actions