收藏
回答

sendTemplateMessage 推送报41028 form_id不正确

框架类型 问题类型 API/组件名称 终端类型 微信版本 基础库版本
小程序 需求 sendTemplateMessage 工具 7.0.0 2.0.0
String accessToken = getAccessToken(requestDTO.getAppId(), requestDTO.getSecret());

String url = "https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token=" + accessToken;
Map<String, Object> param = new HashMap<String, Object>();
param.put("touser", requestDTO.getOpenId());
param.put("template_id", requestDTO.getTemplateId());
param.put("page", "pages/ddctime/ddctime");
param.put("form_id", requestDTO.getFormId());
//TODO
logger.info("weixin push request fomrnId is {}", requestDTO.getFormId());
Map<String, Object> data = new HashMap<String, Object>();
Map<String, Object> keyword1 = new HashMap<String, Object>();
keyword1.put("value", requestDTO.getKeyword1());
data.put("keyword1", keyword1);

Map<String, Object> keyword2 = new HashMap<String, Object>();
keyword2.put("value", requestDTO.getKeyword2());
data.put("keyword2", keyword2);

Map<String, Object> keyword3 = new HashMap<String, Object>();
keyword3.put("value", requestDTO.getKeyword3());
data.put("keyword3", keyword3);

Map<String, Object> keyword4 = new HashMap<String, Object>();
keyword4.put("value", requestDTO.getKeyword4());
data.put("keyword4", keyword4);
param.put("data", data);
logger.info(JsonUtil.objectToJSON(param));
//param.put("mp_template_msg", value);
HttpHeaders headers = new HttpHeaders();
MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
headers.setContentType(type);
headers.add("Accept", MediaType.APPLICATION_JSON.toString());
String params = JsonUtil.objectToJSON(param);
logger.info("weixin push param is {}", params);
HttpEntity<String> formEntity = new HttpEntity<String>(params, headers);
Map<String, Object> resultMap = restTemplate.postForObject(url, formEntity, Map.class);
logger.info(JsonUtil.objectToJSON(resultMap));
logger.info("weixin push result is {}", JsonUtil.objectToJSON(resultMap));
return JsonUtil.objectToJSON(resultMap);



每次都是报41028 form_id不正确,求救

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

1 个回答

  • 痛快科技
    痛快科技
    2019-01-28

    检查你的formid,具体是怎么获取的,格式是什么样的,日志记录输出的是什么?

    2019-01-28
    有用 1
    回复
登录 后发表内容