Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

读取文件并发送提示错误not a valid json #207

Closed
4 tasks done
Pai-Po opened this issue Apr 8, 2024 · 2 comments
Closed
4 tasks done

读取文件并发送提示错误not a valid json #207

Pai-Po opened this issue Apr 8, 2024 · 2 comments

Comments

@Pai-Po
Copy link

Pai-Po commented Apr 8, 2024

⚠️不按照以下格式创建的issue将不会获得回复⚠️

提bug前先检查以下是否已经执行

  • 我已更新了最新版本的代码
  • 我已经仔细地阅读了readme 文档
  • 我已在FAQ里查找了可能寻找的答案
  • 我已经尝试搜索过历史关闭issue寻找可能的答案

bug描述

我在尝试读取一个文件内容并发送,但是更新了最新版本后,出现了这个问题,总是提示request body is not a valid json;我尝试添加了头参数 -H 'Content-Type: multipart/form-data',还是同样的错误提示。

所以请按以下格式描述问题:

  • 场景
  • 读取文件内容并发送
  • 操作
  • curl --location --request POST 'http://localhost:3001/webhook/msg/v2?token=*********' --form 'to={"alias":"Hoster"}' --form content=@"$HOME/demo.jpg"
  • 表现
    {"success":false,"message":"request body is not a valid json! checkout please."}

提供有用的信息

  • 目前使用的版本号:重新拉取了最新版本
  • 提供任何代码片段/日志/输出/截图 以便于帮助快速定位问题
@danni-cool
Copy link
Owner

danni-cool commented Apr 8, 2024

建议使用postman等去处理,手打curl 难免出现问题,以下是刚用postman 验证过的导出的curl格式

curl --location 'http://localhost:3001/webhook/msg?token=FncnVI3ykEy9' \
--form 'to="{alias: \"小号\"}"' \
--form 'content=@"/Users/daniel/Downloads/Jietu20240408-123322@2x.jpg"'

@Pai-Po
Copy link
Author

Pai-Po commented Apr 8, 2024

ok,复制了你的命令测试修改了下,搞定了;有两个点需要注意:

  1. URL中不包含v2
  2. 路径中无法使用$HOME环境变量 (这个可能和curl版本有关)

@Pai-Po Pai-Po closed this as completed Apr 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants