收藏
回答

errcode":40036,"errmsg":"invalid template_id size?

import java.io.IOException;


import org.apache.http.client.ClientProtocolException;

import org.apache.http.client.methods.CloseableHttpResponse;

import org.apache.http.client.methods.HttpPost;

import org.apache.http.entity.StringEntity;

import org.apache.http.impl.client.CloseableHttpClient;

import org.apache.http.impl.client.HttpClients;

import org.apache.http.util.EntityUtils;


import com.alibaba.fastjson.JSONObject;


public class WeixinQuery2 {

    

    private static final String token = "";


    public static void main(String[] args) throws ClientProtocolException, IOException {

        JSONObject data2 = new JSONObject();

            JSONObject keyword1 = new JSONObject();

            keyword1.put("value", " ");

            keyword1.put("color", "#173177");

        data2.put("keyword1", keyword1);

            JSONObject keyword2 = new JSONObject();

            keyword2.put("value", " ");

            keyword2.put("color", "#173177");

        data2.put("keyword2", keyword2);

            JSONObject keyword3 = new JSONObject();

            keyword3.put("value", " ");

            keyword3.put("color", "#173177");

        data2.put("keyword3", keyword3);


        JSONObject mp_template_msg = new JSONObject();

        mp_template_msg.put("appid", "wx2b735862ca820115");

        mp_template_msg.put("template_id", "6-qFl65_1frlx0BlxSi4ds9-j5dliCui-3Wubnvo-nc");

        mp_template_msg.put("data", data2);



        JSONObject body = new JSONObject();

        body.put("touser", "ojYObwyuuiRwabs84UOyJOj1ZDzw");

        body.put("mp_template_msg", mp_template_msg);        


        String url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + token;

        

        

        HttpPost httpPost = new HttpPost(url);

        httpPost.addHeader("Content-Type", "application/json");

        httpPost.setEntity(new StringEntity(body.toJSONString(), "UTF-8"));

        CloseableHttpClient client = HttpClients.createDefault();

        CloseableHttpResponse response = client.execute(httpPost);

        String result = EntityUtils.toString(response.getEntity(), "UTF-8");

        System.out.println(result);

    }

}

回答关注问题邀请回答
收藏

1 个回答

  • 社区技术运营专员--许涛
    社区技术运营专员--许涛
    2023-09-22

    你好,麻烦提供下返回的rid

    2023-09-22
    有用
    回复 1
    • 一元钱
      一元钱
      2023-12-01
      {"errcode":40036,"errmsg":"invalid template_id size rid: 65692daa-4a328b13-65505dc3"}
      2023-12-01
      回复
登录 后发表内容
问题标签