有赞新零售社区

发帖
聊天专版»调用客户创建接口报错

调用客户创建接口报错

孕橙 2018-12-24 1308 浏览 6 评论 | [显示全部楼层] [打印]
生成的token:51bf2d62ecfd31e384b69491cf5eb0af
传入参数:{"birthday":"1987-08-03","gender":1,"name":"李明","remark":"无","contact_address":{"address":"清华西路115号","area_code":"100091"}}


所报错误:

2018-12-24 15:14:45.540 ERROR 12412 --- [nio-9090-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is com.youzan.open.sdk.exception.KDTException: ErrorResponse{code='143001027', msg='null'}] with root cause

com.youzan.open.sdk.exception.KDTException: ErrorResponse{code='143001027', msg='null'}
    at com.youzan.open.sdk.client.core.DefaultYZClient.handleError(DefaultYZClient.java:115) ~[open-sdk-java-2.0.2.jar:na]
    at com.youzan.open.sdk.client.core.DefaultYZClient.invoke(DefaultYZClient.java:90) ~[open-sdk-java-2.0.2.jar:na]

但是把参数放到有赞开放API调试工具里可以

用手机打开
收藏 ··· 回复
    孕橙 青铜   2018-12-24 显示全部楼层
    您好,这个问题是我做测试的,我写了一个方法,调用你们的接口想添加一个客户,就报这个错了

      孕橙 青铜   2018-12-24 显示全部楼层
      以下是代码:
      public void createCustomer() throws Exception{
              YZClient client = new DefaultYZClient(new Token(getYouzanAccessToken())); //new Sign(appKey, appSecret)
              YouzanScrmCustomerCreateParams youzanScrmCustomerCreateParams = new YouzanScrmCustomerCreateParams();

              youzanScrmCustomerCreateParams.setMobile("18632783979");
              YouzanCustom youzanCustom = new YouzanCustom();
              youzanCustom.setBirthday("1987-08-03");
              youzanCustom.setGender(1);
              youzanCustom.setName("李明");
              youzanCustom.setRemark("无");

              YouzanContactAddress youzanContactAddress=new YouzanContactAddress();
              youzanContactAddress.setAddress("清华西路115号");
              youzanContactAddress.setArea_code("100091");

              youzanCustom.setContact_address(youzanContactAddress);

              //转成json字符串
              String json = JSON.toJSON(youzanCustom).toString();
              System.out.println(json);
              youzanScrmCustomerCreateParams.setCustomerCreate(json);

              YouzanScrmCustomerCreate youzanScrmCustomerCreate = new YouzanScrmCustomerCreate();
              youzanScrmCustomerCreate.setAPIParams(youzanScrmCustomerCreateParams);
              YouzanScrmCustomerCreateResult result = client.invoke(youzanScrmCustomerCreate);
          }

        孕橙 青铜   2018-12-24 显示全部楼层
        access_token可以取到

          孕橙 青铜   2018-12-26 显示全部楼层
          导演 发表于 2018-12-24 17:07
          这个报错是resultStr":"{\"error_response\":{\"code\":143001027,\"message\":\"客户已存在\"}}"} 需要 ...


          正解,谢谢了

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

            本版积分规则

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

            • 评分

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

            复制成功