You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Power Automate调用AWS Lambda HTTP端点GET请求失败

Power Automate调用AWS Lambda端点JSON解析错误解决办法

问题原因

你的AWS Lambda函数返回的响应体是纯文本Hello World from AWS,但Power Automate的HTTP请求动作默认会把响应内容当作JSON格式解析。纯文本的首字符是'H',不符合JSON的语法规则(JSON开头应为{、[、双引号或数字),因此触发了解析错误:

Http request failed: the content was not a valid JSON. Error while parsing JSON: 'Unexpected character encountered while parsing value: H. Path '', line 0, position 0.'

两种解决方式

方式一:修改Lambda函数返回标准JSON响应

修改Lambda代码,将响应体转为JSON字符串,并明确指定响应头的Content-Type为application/json,让Power Automate识别为合法JSON:

import json

def lambda_handler(event, context):
    return {
        'statusCode': 200,
        'headers': {
            'Content-Type': 'application/json'
        },
        'body': json.dumps({'message': 'Hello World from AWS'})
    }

方式二:调整Power Automate的HTTP请求配置

如果不需要返回JSON,可让Power Automate不强制解析响应内容:

  • 编辑流中的HTTP请求动作
  • 展开高级选项
  • 将"响应正文"的解析设置改为"不解析"(不同版本表述可能略有差异)
  • 保存后重新测试流即可获取纯文本响应

内容的提问来源于stack exchange,提问作者Parth Karia

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.16 13:35:32