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

GraphQL文件上传cURL请求触发JSONDecodeError,寻求问题排查帮助

问题分析与解决方案

核心问题:JSON语法错误

你的operations参数里的JSON存在语法错误:在"saveName": "hello" }之后错误使用了数组闭合符],而这里应该用对象闭合符}。这个语法错误直接导致JSON解析器无法正确解码请求内容,抛出了json.decoder.JSONDecodeError。

修正后的cURL命令

将错误的]替换为},修正后的完整命令如下:

curl http://localhost:3001/graphql/  -F operations='{ "query": "mutation ConvertDocToPDF($input: ConvertWordDocToPDFInputType!){ convertDocToPDF(input: $input){ success } } ", "variables": { "input" : { "file": null, "saveName": "hello" } } }' -F map='{ "0": ["variables.input.file"] }' -F 0=@README.md

额外注意事项

  • 确保你的Flask GraphQL服务器已配置支持multipart/form-data格式请求,多数GraphQL库需要额外启用文件上传扩展(比如Ariadne的upload_scalar、Graphene的FileUpload)才能处理这类请求。
  • 确认GraphQL schema中ConvertWordDocToPDFInputType的file字段类型为上传标量(如Upload),否则服务器无法识别文件参数。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.05 14:20:26