调用订阅消息send接口为什么一直报40001错误?
发布于 3 年前 作者 na44 13431 次浏览 来自 官方Issues

调用subscribeMessage.send方法时一直报40001,但是明明代码就是按文档写的啊,而且postman测试这个接口也报40001错误

代码片段如下:

String url = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=ACCESS_TOKEN";
url.replace("ACCESS_TOKEN",access_token);
RestTemplate restTemplate = new RestTemplate();
Map<String,String> data = new HashMap<>();
data.put("touser",openid);
data.put("template_id",template_id);
data.put("page","index");
data.put("data","{"name1": {"value": "clare"},"date01": {"value": "20150105"},"thing4":{"value":"hello world"}}");
String forObject = restTemplate.postForObject(url,null,String.class,data);
3 回复

还有一点 resttemplate 在使用post方法传参时,不能用hashmap,会报请求体为空,应该使用linkedmultivaluemap

url = url.replace("ACCESS_TOKEN",access_token);

40001 获取 access_token 时 AppSecret 错误,或者 access_token 无效。

回到顶部