In my project i have to create a py that call a lambda function passing body parameters, i write this code:
import boto3
import json
import base64
client = boto3.client(‘lambda’)
d = {'calID': '[email protected]', 'datada': '2017-12-22T16:40:00+01:00', 'dataa': '2017-12-22T17:55:00+01:00', 'email': '[email protected]'}
s = json.dump(d)
s64 = base64.b64encode(s.encode('utf-8'))
response = client.invoke(
FunctionName='arn:aws:lambda:eu-west-1:13737373737:function:test',
InvocationType='RequestResponse',
LogType='None',
ClientContext='None',
Payload=s64
)
but when response run this error is generated:
InvalidRequestContentException: An error occurred (InvalidRequestContentException) when calling the Invoke operation: Could not parse request body into json: Unrecognized token 'eyJjYWxJRCI6ICI5MmRxaXNzNWJnODdldGNxZWVhbWxtb2IyZ0Bncm91cC5jYWxlbmRhci5nb29nbGUuY29tIiwgImRhdGFkYSI6ICIyMDE3LTEyLTIyVDE2OjQwOjAwKzAxOjAwIiwgImRhdGFhIjogIjIwMTctMTItMjJUMTc6NTU6MDArMDE6MDAiLCAiZW1haWwiOiAibHVjYV9ncmV6eml4eEBob3RtYWlsLmNvbSJ9': was expecting ('true', 'false' or 'null') at [Source: [B@4587098d; line: 1, column: 481]
what this mean?
Many thanks in advance
Payload=json.dumps(d)
. Nothing else is neededs
:Pjson.dumps
. Edited the previous comment as well. Please also see github.com/cleesmith/boto3_test/blob/master/invoke.py#L42