{"code":"SIGN_ERROR","detail":{"detail":{"issue":"sign not match"},"field":"signature","location":"authorization","sign_information":{"method":"POST","sign_message_length":334,"truncated_sign_message":"POST\n/v3/fund-app/mch-transfer/transfer-bills\n1736994722\na2d8f3c28a484de8b418d800b46082cd\n{\"appid\"\n","url":"/v3/fund-app/mch-transfer/transfer-bills"}},"message":"错误的签名,验签失败"}
一直显示错误的签名,用官方的SDK还是自己写的,都是一样的问题。。真不知道错哪了
已解决问题了。。未用官方的SDK,自己写的签名算法。问题的主要原因还是Http的Body未指定UTF-8的编码。
CloseableHttpClient client = HttpClients.createDefault(); HttpPost post = new HttpPost(url); post.setHeader("Authorization", authorization); post.setHeader("Accept", "application/json"); post.setHeader("Wechatpay-Serial", merchantSerialNumber); post.setHeader("Content-Type", "application/json"); // 之前就是这里未指定UTF-8编码,造成签名错误 StringEntity stringEntity = new StringEntity(jsonInputString, ContentType.APPLICATION_JSON, "UTF-8", false); post.setEntity(stringEntity); CloseableHttpResponse response = client.execute(post); HttpEntity entity = response.getEntity(); String resData = EntityUtils.toString(entity);
用的哪个sdk ?贴代码