{
"touser": "xxxxxx",
"template_id": "xxxx",
"page": "/page/gongdan/index",
"data": {
"thing7": {
"value": "商务通海"
},
"thing6": {
"value": "查看服务"
},
"thing2": {
"value": "工商局递"
},
"phrase5": {
"value": "待报名"
}
}
}
13:22:36.062 [main] DEBUG org.springframework.web.client.RestTemplate - HTTP GET https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=xxxxxx&secret=xxxxx
13:22:36.110 [main] DEBUG org.springframework.web.client.RestTemplate - Accept=[application/xml, text/xml, application/json, application/*+xml, application/*+json]
13:22:36.450 [main] DEBUG org.springframework.web.client.RestTemplate - Response 200 OK
13:22:36.452 [main] DEBUG org.springframework.web.client.RestTemplate - Reading to [xin.zhulin.component.weapp.subscribe.message.AccessToken]
{"touser":"xxxxx","template_id":"xxxxx","page":"/page/gongdan/index","data":{"thing7":{"value":"商务通海"},"thing6":{"value":"查看服务"},"thing2":{"value":"工商局递"},"phrase5":{"value":"待报名"}}}
13:22:36.511 [main] DEBUG org.springframework.web.client.RestTemplate - HTTP POST https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=....
13:22:36.511 [main] DEBUG org.springframework.web.client.RestTemplate - Accept=[text/plain, application/xml, text/xml, application/json, application/*+xml, application/*+json, */*]
13:22:36.512 [main] DEBUG org.springframework.web.client.RestTemplate - Writing [{"touser":"xxxxx","template_id":"xxxxx","page":"/page/gongdan/index","data":{"thing7":{"value":"商务通海"},"thing6":{"value":"查看服务"},"thing2":{"value":"工商局递"},"phrase5":{"value":"待报名"}}}] with org.springframework.http.converter.StringHttpMessageConverter
13:22:36.656 [main] DEBUG org.springframework.web.client.RestTemplate - Response 200 OK
13:22:36.657 [main] DEBUG org.springframework.web.client.RestTemplate - Reading to [java.lang.String] as "application/json;encoding=utf-8"
{"errcode":47003,"errmsg":"argument invalid! data.phrase5.value invalid rid: 6138489e-2737e3e3-5f80c795"}
如何更改这个编码?
字数没超过五个,怀疑是中文编码问题
RestTemplate restTemplate = new RestTemplate(); restTemplate.getMessageConverters().set(1, new StringHttpMessageConverter(StandardCharsets.UTF_8));