Invalid base64 error Lambda AWS CLI
The Invalid base64 error occurs when invoking a lambda from the AWS CLI because the default --payload
parameter expects base64
encoding.
1aws lambda invoke --function-name test --payload '{"movie": "John Wick"}' response.json
Error output:
1Invalid base64: "{"movie": "John Wick"}"
Solve Invalid base64
lambda invoke error
To solve the Invalid base64 error, supply the --cli-binary-format
parameter with the value raw-in-base64-out
:
1aws lambda invoke --function-name test --cli-binary-format raw-in-base64-out --payload '{"movie": "John Wick"}' response.json
Output:
1{
2 "StatusCode": 200,
3 "ExecutedVersion": "$LATEST"
4}
Invoke a lambda using a file
A user may opt to supply a .json
file:
1{
2 "movie": "John Wick"
3}
1aws lambda invoke --function-name test --cli-binary-format raw-in-base64-out --payload file://request.json response.json