<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.8.16</version>
</dependency>
导入的包
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.json.JSONUtil;
import lombok.extern.slf4j.Slf4j;
service代码
String url = "http://www.baidu.com";
String base64 = "111";
HashMap<String, Object> paramMap = new HashMap<>();
paramMap.put("base64",base64);
paramMap.put("powerFilePath","C:\\Users\\26896\\Desktop\\aaa");
String body = JSONUtil.toJsonPrettyStr(paramMap);
// 创建 POST 请求
HttpRequest request = HttpRequest.post(url);
// 设置请求头部
request.header("Content-Type", "application/json");
// 设置请求体数据
request.body(body);
// 发送请求并获取响应
HttpResponse response = request.execute();
// 获取响应状态码
int responseCode = response.getStatus();
System.out.println("Response Code: " + responseCode);
// 读取响应数据
String responseBody = response.body();
// 打印响应数据
System.out.println("Response: " + responseBody);