调用这个接口,总是返回412,求助,代码如下:
String accessToken = wechatClient.getAccessToken();
String url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" + accessToken;
Map<String, Object> params = new HashMap<>();
params.put("scene", "test");
params.put("page", "pages/home/home");
params.put("check_path", false);
params.put("env_version", "trial");
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
HttpEntity<Map<String, Object>> requestEntity = new HttpEntity<>(params, headers);
ResponseEntity<String> response = restTemplate.postForEntity(url, requestEntity, String.class);
// ResponseEntity<byte[]> response = restTemplate.postForEntity(url, requestEntity, byte[].class);
Map<String, Object> result = new HashMap<>();
result.put("success", response.getStatusCode().is2xxSuccessful());
result.put("statusCode", response.getStatusCode().value());
result.put("responseBody", response.getBody());
if (response.getBody() != null && response.getBody().trim().startsWith("{")) {
JSONObject json = JSONUtil.parseObj(response.getBody());
result.put("errcode", json.getInt("errcode"));
result.put("errmsg", json.getStr("errmsg"));
}
return R.ok("原始二维码测试完成", result);
具体日志:
2025-09-29 21:34:24 [XNIO-1 task-2] DEBUG o.s.web.client.RestTemplate
- HTTP POST https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=96_D-TSbDE1S-T0N1MO1LU9aZG6U26JI_RsD8BYVJUkzok4junXQXeJP3Q1wsvaX17KtqQ-b5gObrqvZXL4gr3bzDyb4pVqlq-usvHYtWEgJsswsJNES_vRpjly-DsYXGaAEATSB
2025-09-29 21:34:24 [XNIO-1 task-2] DEBUG o.s.web.client.RestTemplate
- Accept=[text/plain, application/json, application/yaml, application/*+json, */*]
2025-09-29 21:34:24 [XNIO-1 task-2] DEBUG o.s.web.client.RestTemplate
- Writing [{check_path=false, page=pages/home/home, scene=test, env_version=trial}] as "application/json"
2025-09-29 21:34:24 [XNIO-1 task-2] DEBUG o.s.web.client.RestTemplate
- Response 412 PRECONDITION_FAILED
这是我小程序状态,没发布过,但是审核通过了,现在在测试阶段!

代码问题,跟发布没关系。换个 springboot 版本,或者 httpcilent 就不报错了
感谢大佬!
话说这个到底啥原因啊,有说法么