- 后台请求微信小程序退款接口,提示解析 json 失败?
https://api.mch.weixin.qq.com/v3/refund/domestic/refunds json 参数在本地可以格式化 Q�Q�M-.NL�=������/�����}��Es_lk}���źEO{�>�_���+� ,解析json失败:Unexpected character ('�' (code 65533 / 0xfffd)): expected a valid value (JSON String, Number, Array, Object or token 'null', 'true' or 'false')
2022-09-09 - java后端请求httpClient发送http请求,返回412状态码
https://developers.weixin.qq.com/miniprogram/dev/framework/server-ability/backend-api.html String appId = ""; String appSerc = ""; String jsCode = "";//登录时的code String url = "https://api.weixin.qq.com/sns/jscode2session?appid=" + appId + "&secret=" + appSerc + "&js_code=" + jsCode + "&grant_type=authorization_code"; System.out.println(url); HttpGet httpGet = new HttpGet(url); HttpClientBuilder httpClientBuilder = HttpClientBuilder.create(); try ( CloseableHttpClient client = httpClientBuilder.build(); CloseableHttpResponse response = client.execute(httpGet); ){ log.info("状态码:"+response.getStatusLine().getStatusCode(),this); System.out.println("返回结果:" + JSON.toJSONString(response.getEntity())); }catch (Exception e){ e.printStackTrace(); } 输出: https://api.weixin.qq.com/sns/jscode2session?appid=&secret=&js_code=&grant_type=authorization_code 状态码:200 {"chunked":false,"content":{},"contentLength":78,"contentType":{"buffer":{"empty":false,"full":false},"elements":[{"name":"text/plain","parameterCount":0,"parameters":[]}],"name":"Content-Type","value":"text/plain","valuePos":13},"repeatable":false,"streaming":true} 这里把id和code去掉了,如果加上,httpClient也是没有办法发出请求
2020-05-13