boto3: where is the Payload attribute of the object returned by `Lambda.Client.invoke` documented?

0

I'd like to read the documentation (if it exists) describing the attributes and methods of the Payload attribute in the object returned by Lambda.Client.invoke` in the boto3 library . I haven't been able to find it by searching and browsing the boto3 docs. Please post a link to the official docs, not an explanation.

Given the state of the boto3 docs, is it preferable to just use API calls directly?

stu
질문됨 한 달 전183회 조회
1개 답변
0

Hello.

"'Payload'" included in the response is called "StreamingBody", so you need to use "read()" to check the contents.
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/lambda/client/invoke.html

"StreamingBody" is described in the following document.
https://botocore.amazonaws.com/v1/documentation/api/latest/reference/response.html

For example, if you check the response without using "read()", it will look like the following.  

import boto3

client = boto3.client('lambda')

response = client.invoke(
        FunctionName='kobayashi-test')
print(response["Payload"])
<botocore.response.StreamingBody object at 0x7f0ce6004dc0>

You can check the return of the Lambda you called by using "read()".

import boto3

client = boto3.client('lambda')

response = client.invoke(
        FunctionName='kobayashi-test')
print(response["Payload"].read())
b'{"statusCode": 200, "body": "\\"Hello from Lambda!\\""}'
profile picture
전문가
답변함 한 달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠