Amazon AWS CLI不允许有效载荷参数中包含有效JSON [英] Amazon AWS CLI not allowing valid JSON in payload parameter

查看:205
本文介绍了Amazon AWS CLI不允许有效载荷参数中包含有效JSON的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试从AWS CLI调用lambda函数时遇到错误.我正在使用CLI的版本2. 我知道我应该将--payload参数作为包含JSON对象的字符串传递.

I am getting an error when I try and invoke a lambda function from the AWS CLI. I am using version 2 of the CLI. I understand that I should pass the --payload argument as a string containing a JSON object.

aws lambda invoke --function-name testsms  --invocation-type Event --payload '{"key": "test"}' response.json 

我收到以下错误:

Invalid base64: "{"key": "test"}"

我尝试了JSON转义字符等的各种变体.我也尝试使用file://test.json选项,但我收到相同的错误.

I have tried all sorts of variants for the JSON escaping characters etc. I have also tried to use the file://test.json option I receive the same error.

推荐答案

正如@MCI所说,AWS V2默认为base 64输入.为了使您的案例有效,只需在命令中添加一个--cli-binary-format raw-in-base64-out参数即可,

As @MCI said, AWS V2 defaults to base 64 input. For your case to work, simply add a --cli-binary-format raw-in-base64-out parameter to your command, so it'd be

aws lambda invoke --function-name testsms \
    --invocation-type Event \
    --cli-binary-format raw-in-base64-out \
    --payload '{"key": "test"}' response.json

这篇关于Amazon AWS CLI不允许有效载荷参数中包含有效JSON的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆