| | |
| | | */
|
| | | public static String sendPostJson(String url, String jsonParam) {
|
| | | // 重载调用,默认使用UTF-8编码,Content-Type固定为application/json
|
| | | return sendPostJson(url, jsonParam, StandardCharsets.UTF_8.name(),null);
|
| | | return sendPostJson(url, jsonParam, StandardCharsets.UTF_8.name(), null, "");
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | */
|
| | | public static String sendPostJson(String url, String jsonParam, String headerValue) {
|
| | | // 重载调用,默认使用UTF-8编码,Content-Type固定为application/json
|
| | | return sendPostJson(url, jsonParam, StandardCharsets.UTF_8.name(),headerValue);
|
| | | return sendPostJson(url, jsonParam, StandardCharsets.UTF_8.name(),headerValue,"");
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | * @param charset 编码类型(如UTF-8、GBK等,建议使用StandardCharsets常量)
|
| | | * @return 远程资源的响应结果
|
| | | */
|
| | | public static String sendPostJson(String url, String jsonParam, String charset,String headerValue) {
|
| | | public static String sendPostJson(String url, String jsonParam, String charset,String headerValue,String accessToken) {
|
| | | PrintWriter out = null;
|
| | | BufferedReader in = null;
|
| | | StringBuilder result = new StringBuilder();
|
| | |
| | | if(StringUtils.isNotEmpty(headerValue)){
|
| | | conn.setRequestProperty("Authorization", headerValue);
|
| | | }
|
| | | if (StringUtils.isNotEmpty(accessToken)) {
|
| | | conn.setRequestProperty("x-acs-dingtalk-access-token", accessToken);
|
| | | }
|
| | | // 2. 开启输入输出流(POST请求必须)
|
| | | conn.setDoOutput(true);
|
| | | conn.setDoInput(true);
|