SpringBoot调用第三方接口,hutool调用

Hutool工具类之HttpUtil使用Https

第一步:先引入夹包


   cn.hutool
   hutool-all
   4.1.0

第二步:实例调用

JSONObject json = new JSONObject();
json.put("name", "阿泽爱开发");
json.put("sex", "1.");

HttpRequest.post("https://....")
        .header("Content-Type", "application/json")//这里head可以继续添加
        .header("token","aaa123123")
        .body(json)
        .execute().body();

第三步:注意事项

import cn.hutool.http.HttpRequest;
import cn.hutool.json.JSONObject;

你可能感兴趣的:(spring,boot,java,spring)