33

I'm trying to call another lambda function from an existing lambda fucntion as below (python 2.7)

from __future__ import print_function
import boto3
import json

lambda_client = boto3.client('lambda')

def lambda_handler(event, context):

    invoke_response = lambda_client.invoke(FunctionName="teststack",
                                           InvocationType='RequestResponse'
                                           )
    print(invoke_response)

    return str(invoke_response)

I'm gettting the below response instead of an actual result. When I run teststack lambda invidually it works fine, but getting below response instead of "test" returned by the teststack Lambda function.

{u'Payload': <botocore.response.StreamingBody object at ****>, 'ResponseMetadata': {'HTTPStatusCode': 200, 'RequestId': '******', 'HTTPHeaders': {'x-amzn-requestid': '******', 'content-length': '155', 'x-amzn-remapped-content-length': '0', 'connection': 'keep-alive', 'date': 'Sun, 17 Jul 2016 21:02:01 GMT', 'content-type': 'application/json'}}, u'StatusCode': 200}
4
  • 1
    i got solution from this thread stackoverflow.com/questions/36784925/… THanks!! Commented Jul 18, 2016 at 1:11
  • 1
    Possible duplicate of how to get return response from AWS Lambda function Commented May 21, 2017 at 0:23
  • @Gricey, the other question deals with asynchronous call (HTTP 202, "Event"). Here it's a synchronous call (HTTP 200, "RequestResponse"). So... Not a duplicate. At least not this one. Commented Oct 7, 2017 at 10:00
  • 1
    @GrzegorzOledzki the answer to the duplicate I link says that they should be using RequestResponse. However I've added an answer so that there's something here for the question as asked. Commented Oct 8, 2017 at 5:33

1 Answer 1

22

The response data you're looking for is there, it's just inside the Payload as a StreamingBody object.

According to the Boto docs, you can read the object using the read method:

invoke_response['Payload'].read()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.