I am trying to follow along the AWS Getting Started with Lambda Tutorial, but I am having Issues actually invoking my Function using the CLI.
I came across THIS step and got two errors:
An error occurred (InvalidRequestContentException) when calling the Invoke operation: Could not parse request body into json: Could not parse payload into json: Unexpected character ((CTRL-CHAR, code 145)): expected a valid value (JSON String, Number, Array, Object or token 'null', 'true' or 'false') at [Source: (byte[])"��j[�"; line: 1, column: 2]
and
An error occurred (ResourceNotFoundException) when calling the GetLogEvents operation: The specified log group does not exist.
I assume the first error is caused by the first command : aws lambda invoke --function-name my-function --payload '{"key": "value"}' out.json
and the second error accordingly by: aws logs get-log-events --log-group-name /aws/lambda/my-function --log-stream-name $(cat out) --limit 5
I am more concerned about the first error. I tried to solve this, by looking at the documentation for invoking a lambda function using the CLI. The most basic example was:
aws lambda invoke --function-name my-function --payload '{ "key": "value" }' response.json
Using this, I get the same Error code
Could not parse payload into json: Unexpected character ((CTRL-CHAR, code 145)):
I have asked about this in the AWS Dev Forums, but have not gotten any answer. There where a few topics about similar errors on Stackoverflow, however they mentioned a specific character that was missing in the payload to be valid JSON. According to google "CTRL-CHAR" sometimes points out a line break in your JSON, but there are none in this example. As far, as I can tell, the payload is valid JSON.
According to the CLI Documentation, you can also use other data types as payload. So I tried just passing a list:
aws lambda invoke --function-name my-func2 --payload '[2, 3, 4, 5]' out.json
I got the error:
Could not parse request body into json: Could not parse payload into json: Unrecognized token 'Û': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')