有赞新零售社区

发帖
API使用问题»{success: false, code: 1000, data: null, message:

[API调用-美业] {success: false, code: 1000, data: null, message:

胡贰 2023-08-22 987 浏览 3 评论 | 只看楼主 [打印]
调用https://open.youzanyun.com/auth/token接口获取accesstoken的时候报错

{success: false, code: 1000, data: null, message: '参数错误'}


但是我反复查了那3个参数没有问题啊
用手机打开
收藏 ··· 回复
    云帆   有赞云团队   2023-08-24 | 只看该作者
    请使用 POST+application/json 请求方式,否则会报错。
    • 胡贰 2023-08-24
      # 获取access_token
              header = {"Content-Type": "application/json"}
              data = {
                        "authorize_type": "silent",
                        "client_id": "690101a02e70XXXXX",
                        "client_secret": "b9ffed6439e945d5a0762c43f9XXXXXX",
                        "grant_id": "13337XXXX",
                        "refresh": False,
                      }
              res = requests.post('https://open.youzanyun.com/auth/token', data=data, headers=header)

      我是用python写的后台 请问我这样写哪里有问题?id和secret都是对的

    云帆   有赞云团队   2023-08-29 | 只看该作者


    请修改代码,obj无法直接作为reqests.post 参数的 data参数
    需要进行json序列转化

    具体代码为:

    1. import json;
    2. res = requests.post('https://open.youzanyun.com/auth/token', data=json.dumps(data), headers=header)
    复制代码



      1跳至
      您需要登录后才可以回帖 登录 | 立即注册

      本版积分规则

      复制链接
      新浪微博
      QQ空间
      微信扫码
      • 回复

      • 评分

      客服工作时间是9:00-18:00,客服妹子当前不在线,若不能及时回复请谅解。试试右上角的搜索吧,论坛有丰富的经验贴、公告贴,相信一定能够帮到您~

      复制成功