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