Hi,
我们之前的集成是基于 有赞开放平台 做的,当时用的你们提供的 Python SDK。现在绑定新店铺发现只支持 有赞云 了,两边的接口稍稍有些不同。我已经稍作修改了原先的 Python SDK(因为有赞云版本API没有提供对应的 Python SDK),调试通过了 认证和 GET 请求,但是现在卡在一个上传图片接口 POST请求 youzan.materials.storage.platform.img.upload https://doc.youzanyun.com/doc#/content/API/1-372/detail/api/0/193 。为了方便调试,我已经抽取出我们的请求为 curl 命令,如下(我把token隐去了):
# 直接填空的
➜ ~ curl -H "User-Agent: X-YZ-Client 2.0.0 - Python;" -H "Content-Type:application/json;charset=UTF-8" -d "{}" https://open.youzanyun.com/api/y ... rm.img.upload/3.0.0\?access_
{"code":160400100,"success":false,"request_id":null,"message":"file参数错误"}
➜ ~ curl -H "User-Agent: X-YZ-Client 2.0.0 - Python;" -H "Content-Type:application/json;charset=UTF-8" -d "{\"\":\"\"}" https://open.youzanyun.com/api/y ... rm.img.upload/3.0.0\?access_token\=123
{"code":160400100,"success":false,"request_id":null,"message":"file参数错误"}
# 填了 image 字段,但是类型是错误的字符串
➜ ~ curl -H "User-Agent: X-YZ-Client 2.0.0 - Python;" -H "Content-Type:application/json;charset=UTF-8" -d "{\"image\":\"\"}" https://open.youzanyun.com/api/y ... rm.img.upload/3.0.0\?access_token\=123
{"gw_err_resp":{"err_code":5001,"err_msg":"系统异常"}}
# 填了正确 image 字段, 无字段名
➜ ~ curl -H "User-Agent: X-YZ-Client 2.0.0 - Python;" -H "Content-Type:application/json;charset=UTF-8" --data-binary "@Pictures/BritishBrands.jpg" https://open.youzanyun.com/api/y ... rm.img.upload/3.0.0\?access_token\=123
{"gw_err_resp":{"err_code":5001,"err_msg":"系统异常"}}
# 填了正确 image 字段, 有字段名
➜ ~ curl -H "User-Agent: X-YZ-Client 2.0.0 - Python;" -H "Content-Type:application/json;charset=UTF-8" -F "image=@Pictures/BritishBrands.jpg" https://open.youzanyun.com/api/y ... rm.img.upload/3.0.0\?access_token\=123
{"gw_err_resp":{"err_code":5001,"err_msg":"系统异常"}}
# 故意填错文件路径
➜ ~ curl -H "User-Agent: X-YZ-Client 2.0.0 - Python;" -H "Content-Type:application/json;charset=UTF-8" -F "image=@Pictures/BritishBrands.jp" https://open.youzanyun.com/api/y ... rm.img.upload/3.0.0\?access_token\=123
curl: (26) couldn't open file "Pictures/BritishBrands.jp"
# 改成另一种方式的字段名,支持数组方式
➜ ~ curl -H "User-Agent: X-YZ-Client 2.0.0 - Python;" -H "Content-Type:application/json;charset=UTF-8" -F "image[]=@Pictures/BritishBrands.jpg" https://open.youzanyun.com/api/y ... rm.img.upload/3.0.0\?access_token\=123
{"gw_err_resp":{"err_code":5001,"err_msg":"系统异常"}}
# 正确 form header
➜ ~ curl -H "User-Agent: X-YZ-Client 2.0.0 - Python;" -H "Content-Type:application/x-www-form-urlencoded" -F 'image=@Pictures/BritishBrands.jpg' https://open.youzanyun.com/api/y ... rm.img.upload/3.0.0\?access_token\=123
{"gw_err_resp":{"err_code":5001,"err_msg":"系统异常"}}
麻烦帮忙解答一下,万分感谢!
|
|
用手机打开
收藏
赞 0
···
回复
|
|
|
|