whitechi73 / OpenShamrock

A Bot Framework based on Lsposed with OneBot11(停止维护/禁用于违法用途)
https://whitechi73.github.io/OpenShamrock
GNU General Public License v3.0
1.41k stars 185 forks source link

bug: 获取资源相关接口使用params没问题,使用json获取提示错误`Lack of param 'file'` #324

Closed MDeath closed 3 months ago

MDeath commented 3 months ago

警告: 在进一步操作之前,请检查下列选项。如果您忽视此模板或者没有提供关键信息,您的 Issue 将直接被关闭

描述 Bug

复现 Bug

使用post发送json都提示缺少file。

requests.post(f'http://{host}:{hp}/get_image', headers=headers, json={"file": "2D914A372EEEAA4C1496C72D709C971B"}).json()
{'status': 'failed',
 'retcode': 10003,
 'data': {'url': '/get_image', 'error': 'Lack of param `file`'}}
requests.post(f'http://{host}:{hp}/get_record',headers=bot.headers,json={"file": "045e0648c1bd549ff0a75f15b9c29fd1","out_format":'mp3'}).json()
{'status': 'failed',
 'retcode': 10003,
 'data': {'url': '/get_record', 'error': 'Lack of param `file`'}}
requests.post(f'http://{host}:{hp}/get_file',headers=bot.headers,json={"file": "045e0648c1bd549ff0a75f15b9c29fd1",'file_type':'base64'}).json()
{'status': 'failed',
 'retcode': 10003,
 'data': {'url': '/get_file', 'error': 'Lack of param `file`'}}

使用params传参就可以

requests.get(f'http://{host}:{hp}/get_image',headers=bot.headers,params={"file": "2D914A372EEEAA4C1496C72D709C971B"}).json()
requests.get(f'http://{host}:{hp}/get_image',headers=bot.headers,params={"file": "2D914A372EEEAA4C1496C72D709C971B"}).json()
{'status': 'ok',
 'retcode': 0,
 'data': {'size': 641505,
  'filename': '2D914A372EEEAA4C1496C72D709C971B',
  'url': 'https://gchat.qpic.cn/gchatpic_new/0/0-0-2D914A372EEEAA4C1496C72D709C971B/0?term=2'},
 'echo': ''}

系统信息

fuqiuluo commented 3 months ago

这个接口貌似没为POST做实现?

fuqiuluo commented 3 months ago
getOrPost("/get_image") {
    val file = formatFileName( fetchGetOrThrow("file") )
    call.respondText(GetImage(file), ContentType.Application.Json)
}

正确的,这个接口只获取了来自GET的参数file!

fuqiuluo commented 3 months ago

https://github.com/whitechi73/OpenShamrock/actions/runs/9395246691