参数输入的类型无效 (step_function.start_execution)

Invalid type for parameter input (step_function.start_execution)

我有一个 start_execution 命令通过我的 lambda 函数启动步进函数 (python):

    if event['Records'][0]['eventName'] == 'INSERT':
            filename, source, destination_bucket_name, filekey = parse_file_info_from_trigger(event)
            response = client.start_execution(
                stateMachineArn='aws:states:.......',
                input = "{\"first_name\" : \"test\"}"       
            )
    else: 
        logger.info(f'This is not an Insert event')

如何将上述提取的变量(文件名、源等)传递到启动执行命令的输入中?

我试过这个:

 response = step_function.start_execution(
                    stateMachineArn=state_machine_zip_files_arn,
                    input = str({ "filename": f"{filename}",  "filetype": f"{filetype}",  "unixtimestamp": f"{unixtimestamp}", 
                    "masterclient": f"{masterclient}", "source_bucket_name": f"{source_bucket_name}" , 
                    "destination_bucket_name": f"{destination_bucket_name}", "filekey": f"{filekey}","this is a test string": f"teststring"})     
                    )

但它给我一个错误:

Unable to start_execution for state machine: An error occurred (InvalidExecutionInput) when calling the StartExecution operation: Invalid State Machine Execution Input: 'Unexpected character (''' (code 39)): was expecting double-quote to start field name'

input 的预期格式是 str。您应该将 dict 转换为 str 如下:json.dumps(your_input_data).