jsoup

引入jsoup和fastjson的maven jar包
jsoup_第1张图片

String url="https://oapi.dingtalk.com/";
//请求数据(格式?两种)
        Map data = new HashMap<>();
        data.put("id","1");
        data.put("gg","2");
        //String json= JSON.toJSONString(data);

        Connection.Response response = Jsoup.connect(url)
                .ignoreContentType(true).data(data)//两个都可以?.requestBody(json)
                .header("Accept", "application/json, text/plain, */*")
                .header("Content-Type", "application/json;charset=UTF-8")
                .method(Connection.Method.POST).timeout(70000).execute();
        String body = response.body();
        JSONObject jsonObject = JSONObject.parseObject(body);
        System.out.println(jsonObject);
        System.out.println(jsonObject.get("errmsg"));

jsoup_第2张图片

你可能感兴趣的:(Java)