第三方平台为授权的小程序帐号上传小程序代码一直报47001
发布于 5 年前 作者 rxiang 3139 次浏览 来自 问答

接口:https://api.weixin.qq.com/wxa/commit?access_token=TOKEN

数据:{“template_id”:0,“ext_json”:{“extEnable”:true,“extAppid”:“wxe6bb636061c7259c”,“ext”:{“upkey”:“p20-mh-2649”}},“user_version”:“1”,“user_desc”:“sdfeefe”}

异常:47001

json格式化通过,为什么总报数据不是json格式?求大神看看。

4 回复

亲测可行

Java 这样写就OK了;大家抄我的:

JsonObject extObj = new JsonObject();

extObj.addProperty("account",account);
extObj.addProperty("template_id",template_id);
extObj.addProperty("merchant_id",merchant_id);

JsonObject ext_json_map = new JsonObject();
ext_json_map.addProperty("extEnable",true);
ext_json_map.addProperty("extAppid",authorizer_appid);
ext_json_map.add("ext",extObj);
String ext_json = ext_json_map.toString();

try {
JsonObject postBuff = new JsonObject();
   postBuff.addProperty("template_id",template_id);
   postBuff.addProperty("ext_json",ext_json);
   postBuff.addProperty("user_version",user_version);
   postBuff.addProperty("user_desc",user_desc);
   String postString = postBuff.toString();

   String retResult = PostUtil.sendPost(wxProperties.getCommit() + authorizer_access_token, postString,"UTF-8");
   JSONObject retJson = JSONObject.fromObject(retResult);

我也碰到这个问题  JSON格式检测 通过 不是格式问题··· !!!

2个小时 整整两个小时  终于搞好了  c# 版

/// 用户上传小程序代码 方法

    /// </summary>

    /// <param name="User_appid">用户的APPID</param>

    /// <param name="mid">小程序在数据库中的ID号 后期匹配webapi下发数据</param>

    /// <returns></returns>

    public string Up_miniProgram(string User_appid, int mid)

    {

        string auth_access_token = new EFT<cc_xcx>().GetModel(x => x.authorizer_appid == User_appid) == null ? "" : new EFT<cc_xcx>().GetModel(x => x.authorizer_appid == User_appid).authorizer_access_token;       

 string ApiUrl = "https://api.weixin.qq.com/wxa/commit?access_token=" + auth_access_token;        

      //获取模板号 和后台行业相对应

        int TempLate_temp = 3       

var ext_online = "{\"extEnable\":true,\"extAppid\":\"" + User_appid + "\",\"ext\":{\"name\":\"xxx\",\"domain\":\"https://www.xxx.com\",\"domain2\":\"https://www.xxx.com\",\"mi\":"+mid+",\"apponline\":\"" + User_appid + "\"},\"window\":{\"backgroundTextStyle\":\"light\",\"navigationBarBackgroundColor\":\"brown\",\"navigationBarTitleText\":\"xxx\",\"navigationBarTextStyle\":\"white\"}}";

        ext_online = JsonHelper.SerializeObject(ext_online);        

       //这一步最关键 一定要转化为JSON string格式   c# string不行 但是API文档上说是String  我开始很郁闷 后来理解了是json序列化后的格式

        var postvalue2 = "{\"template_id\":" + TempLate_temp + ",\"ext_json\":" + ext_online + ",\"user_version\":\"v1.0\",\"user_desc\":\"houselist\"}";

        string res = Set_Wx_api(ApiUrl, "POST", postvalue2);

        return res;

    }


 

  调用:

   

            string msg = new Wx_api().Up_miniProgram(appid, mid); //实例化wx_api类中的上传方法

            return msg; //输出{"errcode":0,"errmsg":"ok"}


 

 


请问你解决了吗

回到顶部