在使用 lambda 时,文档说您必须为 ClientContext 发送一个 base64 编码的 JSON 对象。它还说客户端上下文必须是“str”而不是字节。
http://boto3.readthedocs.io/en/latest/reference/services/lambda.html#Lambda.Client.invoke
由于 python3 的 base64 库现在使用字节而不是字符串进行编码 - 这似乎难倒了我。
import boto3
import base64
CLIENT = boto3.client('lambda')
client_context = b'{ "client_name": "Andy"}'
encoded_context = base64.b64encode(client_context)
CLIENT.invoke(
FunctionName='testFunction',
InvocationType='RequestResponse',
LogType='Tail',
ClientContext=encoded_context
)
Run Code Online (Sandbox Code Playgroud)
我得到的错误是:
Invalid type for parameter ClientContext, value: b'eyAiY2xpZW50X25hbWUiOiJGUkVFSFVCIiB9', type: <class 'bytes'>, valid types: <class 'str'>
或者当我设置str(encoded_context):
botocore.errorfactory.InvalidRequestContentException: An error occurred (InvalidRequestContentException) when calling the Invoke operation: Client context must be a valid Base64-encoded JSON object.
提前致谢。
我想将 github 存储库分叉到 AzureDevOps 中,同时保留 AzureDevOps 中的功能,以按照在 github 中分叉存储库的方式继续从 github 中提取更改。
这是否可行/在路线图上?