Power Automate调用AzureOpenAI Chat Playground HTTP Post报错解决方案
解决Power Automate调用Azure OpenAI Chat Playground的数组类型报错
报错原因
错误''[{"role":"user","content":"Who is mahatma gandhi?"}]' is not of type 'array' - 'messages'的核心问题是:你传递给Azure OpenAI API的messages参数是带引号包裹的字符串,但API要求messages必须是原生JSON数组类型。
解决步骤
- 修正HTTP请求体的
messages字段:直接传入数组内容,不要用引号包裹。比如不要写成"[{\"role\":\"user\",\"content\":\"Who is mahatma gandhi?\"}]",而是使用:[{"role":"user","content":"Who is mahatma gandhi?"}] - 检查动态内容/表达式:如果是通过Power Automate的动态内容或表达式生成
messages,避免用string()这类函数将数组转为字符串,直接输出数组本身。 - 确认请求体格式:完整的JSON请求体示例如下(替换为你的模型信息):
{ "model": "gpt-35-turbo", "messages": [ { "role": "user", "content": "Who is mahatma gandhi?" } ], "temperature": 0.7 } - 验证请求头:确保HTTP动作的
Content-Type设置为application/json,保证API能正确解析请求体的JSON结构。
内容的提问来源于stack exchange,提问作者Farhaan Pasha
相关产品推荐
相关产品推荐

